content: Replace calls to the code shortcode with fenced code blocks

This commit is contained in:
Joe Mooring authored and GitHub committed 2025-03-06 02:49:11 -08:00
1 parent b23c9a583a
commit fd628be6ed
110 files changed
+483 -555

No files matched your search

+6 -6
View File
@@ -14,7 +14,7 @@ By example, let's use [Plotly] to render a chart:
[Plotly]: https://plotly.com/javascript/
{{< code file=contents/example.md lang=text >}}
```text {file="content/example.md"}
{{</* plotly */>}}
{
"data": [
@@ -26,21 +26,21 @@ By example, let's use [Plotly] to render a chart:
],
}
{{</* /plotly */>}}
{{< /code >}}
```
The shortcode is simple:
{{< code file=layouts/shortcodes/plotly.html >}}
```go-html-template {file="layouts/shortcodes/plotly.html"}
{{ $id := printf "plotly-%02d" .Ordinal }}
<div id="{{ $id }}"></div>
<script>
Plotly.newPlot(document.getElementById({{ $id }}), {{ .Inner | safeJS }});
</script>
{{< /code >}}
```
Now we can selectively load the required JavaScript on pages that call the "plotly" shortcode:
{{< code file=layouts/baseof.html >}}
```go-html-template {file="layouts/_default/baseof.html"}
<head>
...
{{ if .HasShortcode "plotly" }}
@@ -48,4 +48,4 @@ Now we can selectively load the required JavaScript on pages that call the "plot
{{ end }}
...
</head>
{{< /code >}}
```