summaryrefslogtreecommitdiffstats
path: root/docs/layouts
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-22 16:47:07 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-22 16:47:07 +0200
commitb95e15694006a16eee41024be88615bda62041cf (patch)
tree3f880d5bc78eaed5b549a50c6cdd219d57e3ac83 /docs/layouts
parent4cac5f5e306b6c301258eb9936094eb910264c9a (diff)
parentf96384a3b596f9bc0a3a035970b09b2c601f0ccb (diff)
Diffstat (limited to 'docs/layouts')
-rw-r--r--docs/layouts/shortcodes/code-toggle.html131
-rw-r--r--docs/layouts/shortcodes/code.html59
-rw-r--r--docs/layouts/shortcodes/content-tree.html14
-rw-r--r--docs/layouts/shortcodes/directoryindex.html13
-rw-r--r--docs/layouts/shortcodes/docfile.html11
-rw-r--r--docs/layouts/shortcodes/exfile.html12
-rw-r--r--docs/layouts/shortcodes/exfm.html13
-rw-r--r--docs/layouts/shortcodes/gh.html9
-rw-r--r--docs/layouts/shortcodes/ghrepo.html1
-rw-r--r--docs/layouts/shortcodes/nohighlight.html1
-rw-r--r--docs/layouts/shortcodes/note.html9
-rw-r--r--docs/layouts/shortcodes/output.html8
-rw-r--r--docs/layouts/shortcodes/tip.html9
-rw-r--r--docs/layouts/shortcodes/warning.html9
-rw-r--r--docs/layouts/shortcodes/yt.html11
15 files changed, 91 insertions, 219 deletions
diff --git a/docs/layouts/shortcodes/code-toggle.html b/docs/layouts/shortcodes/code-toggle.html
index 113d85a1f..b4cfaaa20 100644
--- a/docs/layouts/shortcodes/code-toggle.html
+++ b/docs/layouts/shortcodes/code-toggle.html
@@ -1,87 +1,66 @@
{{- /*
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
-@param {string} config
- Section of site.Data.docs.config to render.
- Example: markup.highlight
- Default: ""
-@param {bool} copy
- Display a copy button.
- Default: true
-@param {string} file
- File name to display above the rendered code.
- Default: ""
-@param {bool} fm
- Does Inner represent front matter?
- Default: false
-@param {string} Inner
- Content between opening and closing shortcode tags.
- Default: ""
-@param {bool} skipHeader
- Omit top level key(s) when rendering a section of site.Data.docs.config.
- Default: false
+@param {string} [config] The section of site.Data.docs.config to render.
+@param {bool} [copy=true] If true, display a copy to clipboard button.
+@param {string} [file] The file name to display above the rendered code.
+@param {bool} [fm=false] If true, render the code as front matter.
+@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config.
+
@returns {template.HTML}
-*/ -}}
+*/}}
-{{- /* Initialize. */ -}}
-{{- $config := "" -}}
-{{- $copy := true -}}
-{{- $file := "" -}}
-{{- $fm := false -}}
-{{- $skipHeader := false -}}
+{{- /* Initialize. */}}
+{{- $config := "" }}
+{{- $copy := true }}
+{{- $file := "" }}
+{{- $fm := false }}
+{{- $skipHeader := false }}
-{{- /* Get parameters, defend against string booleans. */ -}}
-{{- if .Params -}}
- {{- $config = .Get "config" -}}
- {{- $file = .Get "file" -}}
- {{- if (isset .Params "copy") -}}
- {{- if in (slice true "true") (.Get "copy") -}}
- {{- $copy = true -}}
- {{- else -}}
- {{- $copy = false -}}
- {{- end -}}
- {{- end -}}
- {{- if (isset .Params "fm") -}}
- {{- if in (slice true "true") (.Get "fm") -}}
- {{- $fm = true -}}
- {{- else -}}
- {{- $fm = false -}}
- {{- end -}}
- {{- end -}}
- {{- if (isset .Params "skipHeader") -}}
- {{- if in (slice true "true") (.Get "skipHeader") -}}
- {{- $skipHeader = true -}}
- {{- else -}}
- {{- $skipHeader = false -}}
- {{- end -}}
- {{- end -}}
-{{- end -}}
+{{- /* Get parameters. */}}
+{{- $config = .Get "config" }}
+{{- $file = .Get "file" }}
+{{- if in (slice "false" false 0) (.Get "copy") }}
+ {{- $copy = false }}
+{{- else if in (slice "true" true 1) (.Get "copy")}}
+ {{- $copy = true }}
+{{- end }}
+{{- if in (slice "false" false 0) (.Get "fm") }}
+ {{- $fm = false }}
+{{- else if in (slice "true" true 1) (.Get "fm")}}
+ {{- $fm = true }}
+{{- end }}
+{{- if in (slice "false" false 0) (.Get "skipHeader") }}
+ {{- $skipHeader = false }}
+{{- else if in (slice "true" true 1) (.Get "skipHeader")}}
+ {{- $skipHeader = true }}
+{{- end }}
-{{- /* Define constants. */ -}}
-{{- $delimiters := dict "toml" "+++" "yaml" "---" -}}
-{{- $langs := slice "yaml" "toml" "json" -}}
-{{- $placeHolder := "#-hugo-placeholder-#" -}}
+{{- /* Define constants. */}}
+{{- $delimiters := dict "toml" "+++" "yaml" "---" }}
+{{- $langs := slice "yaml" "toml" "json" }}
+{{- $placeHolder := "#-hugo-placeholder-#" }}
-{{- /* Render. */ -}}
-{{- $code := "" -}}
-{{- with $config -}}
- {{- $file = $file | default "config" -}}
- {{- $sections := (split . ".") -}}
- {{- $configSection := index $.Site.Data.docs.config $sections -}}
- {{- $code = dict $sections $configSection -}}
- {{- if $skipHeader -}}
- {{- $code = $configSection -}}
- {{- end -}}
-{{- else -}}
- {{- $code = $.Inner -}}
+{{- /* Render. */}}
+{{- $code := "" }}
+{{- with $config }}
+ {{- $file = $file | default "config" }}
+ {{- $sections := (split . ".") }}
+ {{- $configSection := index $.Site.Data.docs.config $sections }}
+ {{- $code = dict $sections $configSection }}
+ {{- if $skipHeader }}
+ {{- $code = $configSection }}
+ {{- end }}
+{{- else }}
+ {{- $code = $.Inner }}
{{- end }}
<div class="code relative" {{ with $file }}id="{{ . | urlize }}"{{ end }}>
<div class="code-nav flex flex-nowrap items-stretch">
{{- with $file }}
<div class="san-serif f6 dib lh-solid pl2 pv2 mr2">
- {{- . -}}{{- if not $fm -}}.{{- end -}}
+ {{ . }}{{ if not $fm }}.{{ end }}
</div>
- {{- end -}}
+ {{- end }}
{{- range $langs }}
<button data-toggle-tab="{{ . }}" class="tab-button {{ cond (eq . "yaml") "active" "" }} ba san-serif f6 dib lh-solid ph2 pv2">
{{ . }}
@@ -92,17 +71,17 @@ Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
<div class="tab-content">
{{- range $langs }}
<div data-pane="{{ . }}" class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" "" }}">
- {{- $hCode := $code | transform.Remarshal . -}}
- {{- if and $fm (in (slice "toml" "yaml") .) -}}
- {{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder -}}
- {{- end -}}
+ {{- $hCode := $code | transform.Remarshal . }}
+ {{- if and $fm (in (slice "toml" "yaml") .) }}
+ {{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }}
+ {{- end }}
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
</div>
{{- if $copy }}
<button class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
- {{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */ -}}
- {{- end -}}
+ {{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
+ {{- end }}
{{- end }}
</div>
</div>
diff --git a/docs/layouts/shortcodes/code.html b/docs/layouts/shortcodes/code.html
index 0ee25149d..31ca27596 100644
--- a/docs/layouts/shortcodes/code.html
+++ b/docs/layouts/shortcodes/code.html
@@ -1,26 +1,39 @@
-{{ $file := .Get "file" }}
-{{ $codeLang := "" }}
-{{ $suffix := findRE "(\\.[^.]+)$" $file 1 }}
-{{ with $suffix }}
-{{ $codeLang = (index . 0 | strings.TrimPrefix ".") }}
-{{ end }}
-{{ with .Get "codeLang" }}{{ $codeLang = . }}{{ end }}
-{{ if eq $codeLang "html" }}
-{{ $codeLang = "go-html-template" }}
-{{ end }}
-<div class="code relative" id="{{ $file | urlize }}">
- {{- with $file -}}
- <div class="filename san-serif f6 dib lh-solid pl2 pv2">{{ . }}</div>
- {{- end -}}
+{{- /*
+Renders syntax highlighted code.
+
+@param {bool} [copy=true] If true, display a copy to clipboard button.
+@param {string} [file] The file name to display above the rendered code.
+@param {string} [lang] The code language of the inner content.
+
+@returns {template.HTML}
+*/}}
- {{ if ne (.Get "copy") "false" }}
- <button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button">
- </button>
- {{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
- {{ end }}
- <div class="code-copy-content nt3" {{ with .Get "download" }}id="{{ . }}"{{ end }}>
- {{ $inner := trim .Inner "\n" | safeHTML }}
- {{ if .Get "nocode" }}{{ $inner }}{{ else }}{{ with $codeLang }}{{ highlight $inner . "" }}{{ else }}<pre><code>{{ $inner }}</code></pre>{{ end }}{{ end }}
- </div>
+{{- /* Initialize. */}}
+{{- $copy := true }}
+{{- $file := "&nbsp;" }}
+{{- $lang := "" }}
+{{- /* Get parameters. */}}
+{{- $file = .Get "file" }}
+{{- $lang = or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }}
+{{- if in (slice "false" false 0) (.Get "copy") }}
+ {{- $copy = false }}
+{{- else if in (slice "true" true 1) (.Get "copy")}}
+ {{- $copy = true }}
+{{- end }}
+
+{{- /* Use the go-html-template Chroma lexer for HTML. */}}
+{{- if eq $lang "html" }}
+ {{- $lang = "go-html-template" }}
+{{- end }}
+
+{{- /* Render. */}}
+<div class="code relative" id="{{ $file | urlize }}">
+ <div class="f6 dib lh-solid pl2 pv2">{{ or $file "nbsp;" }}</div>
+ {{- if $copy }}
+ <button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
+ {{- end }}
+ <div class="code-copy-content nt3">
+ {{- highlight (trim .Inner "\n\r") $lang }}
+ </div>
</div>
diff --git a/docs/layouts/shortcodes/content-tree.html b/docs/layouts/shortcodes/content-tree.html
deleted file mode 100644
index 0cb527cb5..000000000
--- a/docs/layouts/shortcodes/content-tree.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<div class="code">
- <pre><code>
- ├── blog
- │   ├── _index.md [section]
- │   ├── first-post.md [page]
- │   └── second-post
- │   ├── index.md [page bundle]
- │   └── photo.jpg [page resource]
- └── tags
- ├── _index.md [taxonomy]
- └── funny
- └── _index.md [term]
- </code></pre>
-</div> \ No newline at end of file
diff --git a/docs/layouts/shortcodes/directoryindex.html b/docs/layouts/shortcodes/directoryindex.html
deleted file mode 100644
index 37e7d3ad1..000000000
--- a/docs/layouts/shortcodes/directoryindex.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{{- $pathURL := .Get "pathURL" -}}
-{{- $path := .Get "path" -}}
-{{- $files := readDir $path -}}
-<table>
- <th>Size in bytes</th>
- <th>Name</th>
-{{- range $files }}
- <tr>
- <td>{{ .Size }}</td>
- <td><a href="{{ $pathURL }}{{ .Name | relURL }}" target="_blank"> {{ .Name }}</a></td>
- </tr>
-{{- end }}
-</table>
diff --git a/docs/layouts/shortcodes/docfile.html b/docs/layouts/shortcodes/docfile.html
deleted file mode 100644
index 2f982aae8..000000000
--- a/docs/layouts/shortcodes/docfile.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{{ $file := .Get 0}}
-{{ $filepath := $file }}
-{{ $syntax := index (split $file ".") 1 }}
-{{ $syntaxoverride := eq (len .Params) 2 }}
-<div class="code-copy" id="{{$file | urlize}}">
- <div class="code-copy-header"><div class="action-buttons"></div><span title="" class="filename">{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
- <button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
- <div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
- </button>
- <pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
-</div>
diff --git a/docs/layouts/shortcodes/exfile.html b/docs/layouts/shortcodes/exfile.html
deleted file mode 100644
index 226782957..000000000
--- a/docs/layouts/shortcodes/exfile.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{{ $file := .Get 0}}
-{{ $filepath := replace $file "static/" ""}}
-{{ $syntax := index (split $file ".") 1 }}
-{{ $syntaxoverride := eq (len .Params) 2 }}
-<div class="code-copy" id="{{$file | urlize}}">
- <div class="code-copy-header examplesite"><div class="action-buttons"></div><span class="filename"><i class="icon-website"></i>{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
- <button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
- <div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
- </button>
- <pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
- <a role="button" target="_blank" href="{{$.Site.Params.ghdocsrepo}}{{$file}}" title="See {{$filepath}} source on GitHub" class="tooltip see-on-github" data-tooltip="See {{$filepath}} source on GitHub">Source<i class="icon-github"></i></a>
-</div>
diff --git a/docs/layouts/shortcodes/exfm.html b/docs/layouts/shortcodes/exfm.html
deleted file mode 100644
index c0429bbe1..000000000
--- a/docs/layouts/shortcodes/exfm.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!-- Similar to exfile.html but *only* pulls the front matter from the example/content/*md -->
-{{ $file := .Get 0}}
-{{ $filepath := replace $file "static/" ""}}
-{{ $syntax := index (split $file ".") 1 }}
-{{ $syntaxoverride := eq (len .Params) 2 }}
-<div class="code-copy" id="{{$file | urlize}}">
- <div class="code-copy-header examplesite"><div class="action-buttons"></div><span title="" class="filename">{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
- <button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
- <div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
- </button>
- <pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
- <a role="button" target="_blank" href="{{$.Site.Params.ghdocsrepo}}{{$file}}" title="See {{$filepath}} on GitHub" class="see-on-github">Source<i class="icon-github"></i></a>
-</div> \ No newline at end of file
diff --git a/docs/layouts/shortcodes/gh.html b/docs/layouts/shortcodes/gh.html
deleted file mode 100644
index 981f4b838..000000000
--- a/docs/layouts/shortcodes/gh.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{{ range .Params }}
- {{ if eq (substr . 0 1) "@" }}
- <a href="//github.com/{{ substr . 1 }}">{{ . }}</a>
- {{ else if eq (substr . 0 2) "0x" }}
- <a href="//github.com/gohugoio/hugo/commit/{{ substr . 2 }}">{{ substr . 2 6 }}</a>
- {{ else }}
- <a href="//github.com/gohugoio/hugo/issues/{{ . }}">#{{ . }}</a>
- {{ end }}
-{{ end }}
diff --git a/docs/layouts/shortcodes/ghrepo.html b/docs/layouts/shortcodes/ghrepo.html
deleted file mode 100644
index e9df40d6a..000000000
--- a/docs/layouts/shortcodes/ghrepo.html
+++ /dev/null
@@ -1 +0,0 @@
-<a href="{{$.Site.Params.ghrepo}}" target="_blank">GitHub repository</a> \ No newline at end of file
diff --git a/docs/layouts/shortcodes/nohighlight.html b/docs/layouts/shortcodes/nohighlight.html
deleted file mode 100644
index 238234f17..000000000
--- a/docs/layouts/shortcodes/nohighlight.html
+++ /dev/null
@@ -1 +0,0 @@
-<pre><code class="hljs nohighlight">{{ .Inner }}</code></pre> \ No newline at end of file
diff --git a/docs/layouts/shortcodes/note.html b/docs/layouts/shortcodes/note.html
deleted file mode 100644
index 24d2cd0b2..000000000
--- a/docs/layouts/shortcodes/note.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` }}
-<aside class="admonition note">
- <div class="note-icon">
- {{partial "svg/exclamation.svg" (dict "size" "20px" ) }}
- </div>
- <!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}note{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Note{{end}}</h2> -->
- <!-- <h3>Note</h3> -->
- <div class="admonition-content">{{- .Inner -}}</div>
-</aside>
diff --git a/docs/layouts/shortcodes/output.html b/docs/layouts/shortcodes/output.html
deleted file mode 100644
index e51d284bb..000000000
--- a/docs/layouts/shortcodes/output.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{{$file := .Get "file"}}
-{{$icon := index (split $file ".") 1 }}
-<div class="code" id="{{$file | urlize}}">
- <div class="filename" title="{{$file}}">{{$file}}</div>
- <div class="code-copy-content output-content">
- <pre><code>{{- .Inner | string -}}</code></pre>
- </div>
-</div> \ No newline at end of file
diff --git a/docs/layouts/shortcodes/tip.html b/docs/layouts/shortcodes/tip.html
deleted file mode 100644
index 139e3376b..000000000
--- a/docs/layouts/shortcodes/tip.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` }}
-<aside class="admonition tip">
- <div class="tip-icon">
- {{partial "svg/exclamation.svg" .}}
- </div>
- <!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}tip{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Tip{{end}}</h2> -->
- <!-- <h3>Tip</h3> -->
- <div class="admonition-content">{{- .Inner -}}</div>
-</aside>
diff --git a/docs/layouts/shortcodes/warning.html b/docs/layouts/shortcodes/warning.html
deleted file mode 100644
index c9147be64..000000000
--- a/docs/layouts/shortcodes/warning.html
+++ /dev/null
@@ -1,9 +0,0 @@
-{{ $_hugo_config := `{ "version": 1 }` }}
-<aside class="admonition warning">
- <div class="admonition-icon">
- {{partial "svg/exclamation.svg" .}}
- </div>
- <!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}warning{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Warning{{end}}</h2> -->
- <!-- <h3>Warning</h3> -->
- <div class="admonition-content">{{- .Inner -}}</div>
-</aside>
diff --git a/docs/layouts/shortcodes/yt.html b/docs/layouts/shortcodes/yt.html
deleted file mode 100644
index 6915cec5f..000000000
--- a/docs/layouts/shortcodes/yt.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<div class="video-wrapper" data-streaming="youtube" data-videoid="{{.Get "id"}}" >
- <i class="icon-video-play-button shortcode"></i>
- {{if (.Get "thumbnail")}}
- <div style="background-image:url(/images/thumbnails/{{.Get "thumbnail"}})" alt="YouTube Thumbnail" class="video-thumbnail"></div>
- {{else}}
- <div style="background-image:url(//img.youtube.com/vi/{{.Get "id"}}/0.jpg)" alt="YouTube Thumbnail" class="video-thumbnail"></div>
- {{end}}
-</div>
-{{ if (.Get "description") }}
-<div class="video-description">{{ .Get "description" | markdownify }}</div>
-{{ end }} \ No newline at end of file