mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38'
This commit is contained in:
28
docs/layouts/_shortcodes/chroma-lexers.html
Normal file
28
docs/layouts/_shortcodes/chroma-lexers.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders an HTML template of Chroma lexers and their aliases.
|
||||
|
||||
@example {{< chroma-lexers >}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
<div class="overflow-x-auto">
|
||||
<table>
|
||||
<thead>
|
||||
<th>Language</th>
|
||||
<th>Identifiers</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- range site.Data.docs.chroma.lexers }}
|
||||
<tr>
|
||||
<td>{{ .Name }}</td>
|
||||
<td>
|
||||
{{- range $k, $_ := .Aliases }}
|
||||
{{- if $k }},{{ end }}
|
||||
<code>{{ . }}</code>
|
||||
{{- end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{- end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
120
docs/layouts/_shortcodes/code-toggle.html
Normal file
120
docs/layouts/_shortcodes/code-toggle.html
Normal file
@@ -0,0 +1,120 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
|
||||
|
||||
@param {string} [config] The section of site.Data.docs.config to render.
|
||||
@param {bool} [copy=false] Whether to display a copy-to-clipboard button.
|
||||
@param {string} [dataKey] The section of site.Data.docs to render.
|
||||
@param {string} [file] The file name to display above the rendered code.
|
||||
@param {bool} [fm=false] Whether to render the code as front matter.
|
||||
@param {bool} [skipHeader=false] Whether to omit top level key(s) when rendering a section of site.Data.docs.config.
|
||||
|
||||
@example {{< code-toggle file=hugo config=build />}}
|
||||
|
||||
@example {{< code-toggle file=content/example.md fm="true" }}
|
||||
title='Example'
|
||||
draft='false
|
||||
{{< /code-toggle }}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- /* Initialize. */}}
|
||||
{{- $config := "" }}
|
||||
{{- $copy := false }}
|
||||
{{- $dataKey := "" }}
|
||||
{{- $file := "" }}
|
||||
{{- $fm := false }}
|
||||
{{- $skipHeader := false }}
|
||||
|
||||
{{- /* Get parameters. */}}
|
||||
{{- $config = .Get "config" }}
|
||||
{{- $dataKey = .Get "dataKey" }}
|
||||
{{- $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-#" }}
|
||||
|
||||
{{- /* Render. */}}
|
||||
{{- $code := "" }}
|
||||
{{- if $config }}
|
||||
{{- $file = $file | default "hugo" }}
|
||||
{{- $sections := (split $config ".") }}
|
||||
{{- $configSection := index $.Site.Data.docs.config $sections }}
|
||||
{{- $code = dict $sections $configSection }}
|
||||
{{- if $skipHeader }}
|
||||
{{- $code = $configSection }}
|
||||
{{- end }}
|
||||
{{- else if $dataKey }}
|
||||
{{- $file = $file | default $dataKey }}
|
||||
{{- $sections := (split $dataKey ".") }}
|
||||
{{- $code = index $.Site.Data.docs $sections }}
|
||||
{{- else }}
|
||||
{{- $code = $.Inner }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<div x-data class="shortcode-code not-prose relative p-0 mt-6 mb-8">
|
||||
{{- if $copy }}
|
||||
<svg
|
||||
class="absolute right-4 top-12 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-6 h-6"
|
||||
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
|
||||
<use href="#icon--copy"></use>
|
||||
</svg>
|
||||
{{- end }}
|
||||
<nav class="relative flex" aria-label="Tabs">
|
||||
{{- with $file }}
|
||||
<div
|
||||
class="select-none flex-none text-sm px-2 content-center border-b-1 border-gray-300 dark:border-gray-700"
|
||||
aria-label="Filename">
|
||||
{{ . }}{{ if not $fm }}.{{ end }}
|
||||
</div>
|
||||
{{- end }}
|
||||
{{- range $i, $lang := $langs }}
|
||||
{{- $isLast := eq (add $i 1) (len $langs) }}
|
||||
<button
|
||||
x-on:click="$store.nav.userSettings.settings.configFileType = '{{ index $langs $i }}'"
|
||||
aria-label="{{ printf `Toggle %s` . }}"
|
||||
class="px-3 py-2 font-semibold text-black dark:text-slate-200 border-l-1 border-t-1 {{ if $isLast }}
|
||||
border-r-1
|
||||
{{ end }} border-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 dark:border-gray-700 cursor-pointer relative min-w-0 flex-1 overflow-hidden text-sm no-underline text-center focus:z-10 overflow-x-auto"
|
||||
:class="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}' ? 'border-b-0 bg-light dark:bg-dark' : 'border-b-1'">
|
||||
<span class="select-none">
|
||||
{{ . }}
|
||||
</span>
|
||||
</button>
|
||||
{{- end }}
|
||||
</nav>
|
||||
{{- if $code }}
|
||||
{{- range $i, $lang := $langs }}
|
||||
<div
|
||||
class="max-h-96 overflow-y-auto border-l-1 border-b-1 border-r-1 border-gray-300 dark:border-gray-700"
|
||||
x-ref="{{ $lang }}"
|
||||
x-cloak
|
||||
x-transition:enter.opacity.duration.300ms
|
||||
x-show="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}'">
|
||||
{{- $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>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
47
docs/layouts/_shortcodes/datatable-filtered.html
Normal file
47
docs/layouts/_shortcodes/datatable-filtered.html
Normal file
@@ -0,0 +1,47 @@
|
||||
{{ $package := (index .Params 0) }}
|
||||
{{ $listname := (index .Params 1) }}
|
||||
{{ $filter := split (index .Params 2) " " }}
|
||||
{{ $filter1 := index $filter 0 }}
|
||||
{{ $filter2 := index $filter 1 }}
|
||||
{{ $filter3 := index $filter 2 }}
|
||||
|
||||
{{ $list := (index (index .Site.Data.docs $package) $listname) }}
|
||||
{{ $fields := after 3 .Params }}
|
||||
{{ $list := where $list $filter1 $filter2 $filter3 }}
|
||||
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{{ range $fields }}
|
||||
<th>{{ . }}</th>
|
||||
{{ end }}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $list }}
|
||||
<tr>
|
||||
{{ range $k, $v := . }}
|
||||
{{ $.Scratch.Set $k $v }}
|
||||
{{ end }}
|
||||
{{ range $k, $v := $fields }}
|
||||
<td>
|
||||
{{ $tdContent := $.Scratch.Get . }}
|
||||
{{ if eq $k 3 }}
|
||||
{{ printf "%v" $tdContent |
|
||||
strings.ReplaceRE `\[` "<ol><li>" |
|
||||
strings.ReplaceRE `\s` "</li><li>" |
|
||||
strings.ReplaceRE `\]` "</li></ol>" |
|
||||
safeHTML
|
||||
}}
|
||||
{{ else }}
|
||||
{{ $tdContent }}
|
||||
{{ end }}
|
||||
</td>
|
||||
{{ end }}
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
39
docs/layouts/_shortcodes/datatable.html
Normal file
39
docs/layouts/_shortcodes/datatable.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{{ $package := (index .Params 0) }}
|
||||
{{ $listname := (index .Params 1) }}
|
||||
{{ $list := (index (index .Site.Data.docs $package) $listname) }}
|
||||
{{ $fields := after 2 .Params }}
|
||||
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{{ range $fields }}
|
||||
{{ $s := . }}
|
||||
{{ if eq $s "_key" }}
|
||||
{{ $s = "type" }}
|
||||
{{ end }}
|
||||
<th>{{ $s }}</th>
|
||||
{{ end }}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range $k1, $v1 := $list }}
|
||||
<tr>
|
||||
{{ range $k2, $v2 := . }}
|
||||
{{ $.Scratch.Set $k2 $v2 }}
|
||||
{{ end }}
|
||||
{{ range $fields }}
|
||||
{{ $s := "" }}
|
||||
{{ if eq . "_key" }}
|
||||
{{ $s = $k1 }}
|
||||
{{ else }}
|
||||
{{ $s = $.Scratch.Get . }}
|
||||
{{ end }}
|
||||
<td>{{ $s }}</td>
|
||||
{{ end }}
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
29
docs/layouts/_shortcodes/deprecated-in.html
Normal file
29
docs/layouts/_shortcodes/deprecated-in.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders a callout indicating the version in which a feature was deprecated.
|
||||
|
||||
Include descriptive text between the opening and closing tags, or omit the
|
||||
descriptive text and call the shortcode with a self-closing tag.
|
||||
|
||||
@param {string} 0 The semantic version string, with or without a leading v.
|
||||
|
||||
@example {{< deprecated-in 0.144.0 />}}
|
||||
|
||||
@example {{< deprecated-in 0.144.0 >}}
|
||||
Some descriptive text here.
|
||||
{{< /deprecated-in >}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- with $version := .Get 0 | strings.TrimLeft "vV" }}
|
||||
{{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}
|
||||
{{- $inner := strings.TrimSpace $.Inner }}
|
||||
{{- $text := printf "Deprecated in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }}
|
||||
{{- partial "layouts/blocks/alert.html" (dict
|
||||
"color" "orange"
|
||||
"icon" "exclamation"
|
||||
"text" $text
|
||||
)
|
||||
}}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }}
|
||||
{{- end }}
|
26
docs/layouts/_shortcodes/eturl.html
Normal file
26
docs/layouts/_shortcodes/eturl.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders an absolute URL to the source code for an embedded template.
|
||||
|
||||
Accepts either positional or named parameters, and depends on the
|
||||
embedded_templates.toml file in the data directory.
|
||||
|
||||
@param {string} filename The embedded template's file name, excluding extension.
|
||||
|
||||
@example {{% et robots.txt %}}
|
||||
@example {{% et filename=robots.txt %}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- with $filename := or (.Get "filename") (.Get 0) }}
|
||||
{{- with site.Data.embedded_template_urls }}
|
||||
{{- with index . $filename }}
|
||||
{{- urls.JoinPath site.Data.embedded_template_urls.base_url . }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find a URL for the embedded template named %q. Check the name. See %s" $.Name $filename $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find the embedded_template_urls data file in the site's data directory. See %s" $.Name $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcodes requires a named or positional parameter, the file name of the embedded template, excluding its extension. See %s" .Name .Position }}
|
||||
{{- end -}}
|
18
docs/layouts/_shortcodes/glossary-term.html
Normal file
18
docs/layouts/_shortcodes/glossary-term.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{- /*
|
||||
Renders the definition of the given glossary term.
|
||||
|
||||
@param {string} (.Get 0) The glossary term.
|
||||
|
||||
@example {{% glossary-term float %}}
|
||||
@example {{% glossary-term "floating point" %}}
|
||||
*/ -}}
|
||||
{{- with .Get 0 }}
|
||||
{{- $path := printf "/quick-reference/glossary/%s" (urlize .) }}
|
||||
{{- with site.GetPage $path }}
|
||||
{{ .RenderShortcodes }}{{/* Do not indent. */}}
|
||||
{{- else }}
|
||||
{{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The glossary term (%s) shortcode requires one positional parameter: see %s" $.Name $.Position }}
|
||||
{{- end -}}
|
54
docs/layouts/_shortcodes/glossary.html
Normal file
54
docs/layouts/_shortcodes/glossary.html
Normal file
@@ -0,0 +1,54 @@
|
||||
{{- /*
|
||||
Renders the glossary of terms.
|
||||
|
||||
When you call this shortcode using the {{% %}} notation, the glossary terms are
|
||||
Markdown headings (level 6) which means they are members of .Fragments. This
|
||||
allows the link render hook to verify links to glossary terms.
|
||||
|
||||
Yes, the terms themselves are pages, but we don't want to link to the pages, at
|
||||
least not right now. Instead, we want to link to the ids rendered by this
|
||||
shortcode.
|
||||
|
||||
@example {{% glossary %}}
|
||||
*/ -}}
|
||||
{{- $path := "/quick-reference/glossary" }}
|
||||
{{- with site.GetPage $path }}
|
||||
|
||||
{{- /* Build and render alphabetical index. */}}
|
||||
{{- $m := dict }}
|
||||
{{- range $p := .Pages.ByTitle }}
|
||||
{{- $k := substr .Title 0 1 | strings.ToUpper }}
|
||||
{{- if index $m $k }}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- $anchor := path.BaseName .Path | anchorize }}
|
||||
{{- $m = merge $m (dict $k $anchor) }}
|
||||
{{- end }}
|
||||
{{- range $k, $v := $m }}
|
||||
[{{ $k }}](#{{ $v }}) {{/* Do not indent. */}}
|
||||
{{- end }}
|
||||
|
||||
{{/* Render glossary terms. */}}
|
||||
{{- range $p := .Pages.ByTitle }}
|
||||
{{ .Title }}{{/* Do not indent. */}}
|
||||
: {{ .RawContent | strings.TrimSpace | safeHTML }}{{/* Do not indent. */}}
|
||||
{{ with .Params.reference }}
|
||||
{{- $destination := "" }}
|
||||
{{- with $u := urls.Parse . }}
|
||||
{{- if $u.IsAbs }}
|
||||
{{- $destination = $u.String }}
|
||||
{{- else }}
|
||||
{{- with site.GetPage $u.Path }}
|
||||
{{- $destination = .RelPermalink }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find the reference link %s: see %s" $.Name . $p.String }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
: See [details]({{ $destination }}).{{/* Do not indent. */}}
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}}
|
||||
{{- end }}
|
14
docs/layouts/_shortcodes/hl.html
Normal file
14
docs/layouts/_shortcodes/hl.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Returns syntax-highlighted code from the given text.
|
||||
|
||||
This is useful as a terse way to highlight inline code snippets. Calling the
|
||||
highlight shortcode for inline snippets is verbose.
|
||||
|
||||
@example This is {{< hl python >}}inline{{< /hl >}} code.
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- $code := .Inner | strings.TrimSpace }}
|
||||
{{- $lang := or (.Get 0) "go" }}
|
||||
{{- $opts := dict "hl_inline" true "noClasses" true }}
|
||||
{{- transform.Highlight $code $lang $opts }}
|
391
docs/layouts/_shortcodes/img.html
Normal file
391
docs/layouts/_shortcodes/img.html
Normal file
@@ -0,0 +1,391 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders the given image using the given filter, if any.
|
||||
|
||||
When using the text filter, provide the arguments in this order:
|
||||
|
||||
0. The text
|
||||
1. The horizontal offset, in pixels, relative to the left of the image (default 20)
|
||||
2. The vertical offset, in pixels, relative to the top of the image (default 20)
|
||||
3. The font size in pixels (default 64)
|
||||
4. The line height (default 1.2)
|
||||
5. The font color (default #ffffff)
|
||||
|
||||
When using the padding filter, provide all arguments in this order:
|
||||
|
||||
0. Padding top
|
||||
1. Padding right
|
||||
2. Padding bottom
|
||||
3. Padding right
|
||||
4. Canvas color
|
||||
|
||||
@param {string} src The path to the image which must be a remote, page, or global resource.
|
||||
@param {string} [filter] The filter to apply to the image (case-insensitive).
|
||||
@param {string} [filterArgs] A comma-delimited list of arguments to pass to the filter.
|
||||
@param {bool} [example=false] If true, renders a before/after example.
|
||||
@param {int} [exampleWidth=384] Image width, in pixels, when rendering a before/after example.
|
||||
|
||||
@example {{< img src="zion-national-park.jpg" >}}
|
||||
@example {{< img src="zion-national-park.jpg" alt="Zion National Park" >}}
|
||||
|
||||
@example {{< img
|
||||
src="zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="grayscale"
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="process"
|
||||
filterArgs="resize 400x webp"
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="colorize"
|
||||
filterArgs="180,50,20"
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="grayscale"
|
||||
example=true
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="grayscale"
|
||||
example=true
|
||||
exampleWidth=400
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Text"
|
||||
filterArgs="Zion National Park,25,250,56"
|
||||
example=true
|
||||
>}}
|
||||
|
||||
@example {{< img
|
||||
src="images/examples/zion-national-park.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="Padding"
|
||||
filterArgs="20,50,20,50,#0705"
|
||||
example=true
|
||||
>}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- /* Initialize. */}}
|
||||
{{- $alt := "" }}
|
||||
{{- $src := "" }}
|
||||
{{- $filter := "" }}
|
||||
{{- $filterArgs := slice }}
|
||||
{{- $example := false }}
|
||||
{{- $exampleWidth := 384 }}
|
||||
|
||||
{{- /* Default values to use with the text filter. */}}
|
||||
{{ $textFilterOpts := dict
|
||||
"xOffset" 20
|
||||
"yOffset" 20
|
||||
"fontSize" 64
|
||||
"lineHeight" 1.2
|
||||
"fontColor" "#ffffff"
|
||||
"fontPath" "https://github.com/google/fonts/raw/refs/heads/main/ofl/lato/Lato-Regular.ttf"
|
||||
}}
|
||||
|
||||
{{- /* Get and validate parameters. */}}
|
||||
{{- with .Get "alt" }}
|
||||
{{- $alt = . }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Get "src" }}
|
||||
{{- $src = . }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a file parameter. See %s" .Name .Position }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Get "filter" }}
|
||||
{{- $filter = . | lower }}
|
||||
{{- end }}
|
||||
|
||||
{{- $validFilters := slice
|
||||
"autoorient" "brightness" "colorbalance" "colorize" "contrast" "dither"
|
||||
"gamma" "gaussianblur" "grayscale" "hue" "invert" "mask" "none" "opacity"
|
||||
"overlay" "padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text"
|
||||
"unsharpmask"
|
||||
}}
|
||||
|
||||
{{- with $filter }}
|
||||
{{- if not (in $validFilters .) }}
|
||||
{{- errorf "The filter passed to the %q shortcode is invalid. The filter must be one of %s. See %s" $.Name (delimit $validFilters ", " ", or ") $.Position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Get "filterArgs" }}
|
||||
{{- $filterArgs = split . "," }}
|
||||
{{- $filterArgs = apply $filterArgs "trim" "." " " }}
|
||||
{{- end }}
|
||||
|
||||
{{- if in (slice "false" false 0) (.Get "example") }}
|
||||
{{- $example = false }}
|
||||
{{- else if in (slice "true" true 1) (.Get "example") }}
|
||||
{{- $example = true }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Get "exampleWidth" }}
|
||||
{{- $exampleWidth = . | int }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Get image. */}}
|
||||
{{- $ctx := dict "page" .Page "src" $src "name" .Name "position" .Position }}
|
||||
{{- $i := partial "inline/get-resource.html" $ctx }}
|
||||
|
||||
{{- /* Resize if rendering before/after examples. */}}
|
||||
{{- if $example }}
|
||||
{{- $i = $i.Resize (printf "%dx" $exampleWidth) }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Create filter. */}}
|
||||
{{- $f := "" }}
|
||||
{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }}
|
||||
{{- if eq $filter "autoorient" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $f = images.AutoOrient }}
|
||||
{{- else if eq $filter "brightness" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Brightness (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "colorbalance" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage red" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage green" "argValue" (index $filterArgs 1) "min" -100 "max" 500) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage blue" "argValue" (index $filterArgs 2) "min" -100 "max" 500) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.ColorBalance (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
|
||||
{{- else if eq $filter "colorize" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "hue" "argValue" (index $filterArgs 0) "min" 0 "max" 360) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "saturation" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 2) "min" 0 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Colorize (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
|
||||
{{- else if eq $filter "contrast" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Contrast (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "dither" }}
|
||||
{{- $f = images.Dither }}
|
||||
{{- else if eq $filter "gamma" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "gamma" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Gamma (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "gaussianblur" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.GaussianBlur (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "grayscale" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $f = images.Grayscale }}
|
||||
{{- else if eq $filter "hue" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "shift" "argValue" (index $filterArgs 0) "min" -180 "max" 180) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Hue (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "invert" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $f = images.Invert }}
|
||||
{{- else if eq $filter "mask" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }}
|
||||
{{- $maskImage := partial "inline/get-resource.html" $ctx }}
|
||||
{{- $f = images.Mask $maskImage }}
|
||||
{{- else if eq $filter "opacity" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "opacity" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Opacity (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "overlay" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }}
|
||||
{{- $overlayImg := partial "inline/get-resource.html" $ctx }}
|
||||
{{- $f = images.Overlay $overlayImg (index $filterArgs 1 | float ) (index $filterArgs 2 | float) }}
|
||||
{{- else if eq $filter "padding" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 5) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $f = images.Padding
|
||||
(index $filterArgs 0 | int)
|
||||
(index $filterArgs 1 | int)
|
||||
(index $filterArgs 2 | int)
|
||||
(index $filterArgs 3 | int)
|
||||
(index $filterArgs 4)
|
||||
}}
|
||||
{{- else if eq $filter "pixelate" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "size" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Pixelate (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "process" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $f = images.Process (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "saturation" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Saturation (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "sepia" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Sepia (index $filterArgs 0) }}
|
||||
{{- else if eq $filter "sigmoid" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 2) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "midpoint" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "factor" "argValue" (index $filterArgs 1) "min" -10 "max" 10) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.Sigmoid (index $filterArgs 0) (index $filterArgs 1) }}
|
||||
{{- else if eq $filter "text" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $ctx := dict "src" $textFilterOpts.fontPath "name" .Name "position" .Position }}
|
||||
{{- $font := or (partial "inline/get-resource.html" $ctx) }}
|
||||
{{- $fontSize := or (index $filterArgs 3 | int) $textFilterOpts.fontSize }}
|
||||
{{- $lineHeight := math.Max (or (index $filterArgs 4 | float) $textFilterOpts.lineHeight) 1 }}
|
||||
{{- $opts := dict
|
||||
"x" (or (index $filterArgs 1 | int) $textFilterOpts.xOffset)
|
||||
"y" (or (index $filterArgs 2 | int) $textFilterOpts.yOffset)
|
||||
"size" $fontSize
|
||||
"linespacing" (mul (sub $lineHeight 1) $fontSize)
|
||||
"color" (or (index $filterArgs 5) $textFilterOpts.fontColor)
|
||||
"font" $font
|
||||
}}
|
||||
{{- $f = images.Text (index $filterArgs 0) $opts }}
|
||||
{{- else if eq $filter "unsharpmask" }}
|
||||
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
|
||||
{{- template "validate-arg-count" $ctx }}
|
||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 500) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "amount" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $ctx = merge $ctx (dict "argName" "threshold" "argValue" (index $filterArgs 2) "min" 0 "max" 1) }}
|
||||
{{- template "validate-arg-value" $ctx }}
|
||||
{{- $f = images.UnsharpMask (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Apply filter. */}}
|
||||
{{- $fi := $i }}
|
||||
{{- with $f }}
|
||||
{{- $fi = $i.Filter . }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* Render. */}}
|
||||
{{- $class := "border-1 border-gray-300 dark:border-gray-500" }}
|
||||
{{- if $example }}
|
||||
<p>Original</p>
|
||||
<img
|
||||
class="{{ $class }}"
|
||||
src="{{ $i.RelPermalink }}"
|
||||
alt="{{ $alt }}">
|
||||
<p>Processed</p>
|
||||
<img
|
||||
class="{{ $class }}"
|
||||
src="{{ $fi.RelPermalink }}"
|
||||
alt="{{ $alt }}">
|
||||
{{- else -}}
|
||||
<img
|
||||
src="{{ $fi.RelPermalink }}"
|
||||
alt="{{ $alt }}">
|
||||
{{- end }}
|
||||
|
||||
{{- define "validate-arg-count" }}
|
||||
{{- $msg := "When using the %q filter, the %q shortcode requires an args parameter with %d %s. See %s" }}
|
||||
{{- if lt (len .args) .argsRequired }}
|
||||
{{- $text := "values" }}
|
||||
{{- if eq 1 .argsRequired }}
|
||||
{{- $text = "value" }}
|
||||
{{- end }}
|
||||
{{- errorf $msg .filter .name .argsRequired $text .position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "validate-arg-value" }}
|
||||
{{- $msg := "The %q argument passed to the %q shortcode is invalid. Expected a value in the range [%v,%v], but received %v. See %s" }}
|
||||
{{- if or (lt .argValue .min) (gt .argValue .max) }}
|
||||
{{- errorf $msg .argName .name .min .max .argValue .position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "_partials/inline/get-resource.html" }}
|
||||
{{- $r := "" }}
|
||||
{{- $u := urls.Parse .src }}
|
||||
{{- $msg := "The %q shortcode was unable to resolve %s. See %s" }}
|
||||
{{- if $u.IsAbs }}
|
||||
{{- with try (resources.GetRemote $u.String) }}
|
||||
{{- with .Err }}
|
||||
{{- errorf "%s" . }}
|
||||
{{- else with .Value }}
|
||||
{{- /* This is a remote resource. */}}
|
||||
{{- $r = . }}
|
||||
{{- else }}
|
||||
{{- errorf $msg $.name $u.String $.position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- with .page.Resources.Get (strings.TrimPrefix "./" $u.Path) }}
|
||||
{{- /* This is a page resource. */}}
|
||||
{{- $r = . }}
|
||||
{{- else }}
|
||||
{{- with resources.Get $u.Path }}
|
||||
{{- /* This is a global resource. */}}
|
||||
{{- $r = . }}
|
||||
{{- else }}
|
||||
{{- errorf $msg $.name $u.Path $.position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $r }}
|
||||
{{- end -}}
|
39
docs/layouts/_shortcodes/imgproc.html
Normal file
39
docs/layouts/_shortcodes/imgproc.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders the given image using the given process specification.
|
||||
|
||||
@param {string} path The path to the image, either a page resource or a global resource.
|
||||
@param {string} spec The image processing specification.
|
||||
@param {string} alt The alt attribute of the img element.
|
||||
|
||||
@example {{< imgproc path="sunset.jpg" spec="resize 300x" alt="A sunset" >}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- with $.Get "path" }}
|
||||
{{- with $i := or ($.Page.Resources.Get .) (resources.Get .) }}
|
||||
{{- with $spec := $.Get "spec" }}
|
||||
{{- with $i.Process . }}
|
||||
<figure>
|
||||
<img
|
||||
src="{{ .RelPermalink }}"
|
||||
width="{{ .Width }}"
|
||||
height="{{ .Height }}"
|
||||
alt="{{ $.Get `alt` }}">
|
||||
<figcaption class="not-prose text-sm">
|
||||
{{- with $.Inner }}
|
||||
{{ . }}
|
||||
{{- else }}
|
||||
{{ $spec }}
|
||||
{{- end }}
|
||||
</figcaption>
|
||||
</figure>
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a 'spec' argument containing the image processing specification. See %s" $.Name $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a 'path' argument indicating the image path. The image must be a page resource or a global resource. See %s" $.Name $.Position }}
|
||||
{{- end }}
|
20
docs/layouts/_shortcodes/include.html
Normal file
20
docs/layouts/_shortcodes/include.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders the page using the RenderShortcode method on the Page object.
|
||||
|
||||
You must call this shortcode using the {{% %}} notation.
|
||||
|
||||
@param {string} (positional parameter 0) The path to the page, relative to the content directory.
|
||||
|
||||
@example {{% include "functions/_common/glob-patterns" %}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- with .Get 0 }}
|
||||
{{- with or ($.Page.GetPage .) (site.GetPage .) }}
|
||||
{{- .RenderShortcodes }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a positional parameter indicating the path of the file to include. See %s" .Name .Position }}
|
||||
{{- end }}
|
69
docs/layouts/_shortcodes/list-pages-in-section.html
Normal file
69
docs/layouts/_shortcodes/list-pages-in-section.html
Normal file
@@ -0,0 +1,69 @@
|
||||
{{- /*
|
||||
Renders a description list of the pages in the given section.
|
||||
|
||||
Render a subset of the pages in the section by specifying a predefined filter,
|
||||
and whether to include those pages.
|
||||
|
||||
Filters are defined in the data directory, in the file named page_filters. Each
|
||||
filter is an array of paths to a file, relative to the root of the content
|
||||
directory. Hugo will throw an error if the specified filter does not exist, or
|
||||
if any of the pages in the filter do not exist.
|
||||
|
||||
@param {string} path The path to the section.
|
||||
@param {string} [filter=""] The name of filter list.
|
||||
@param {string} [filterType=""] The type of filter, either include or exclude.
|
||||
@param {string} [titlePrefix=""] The string to prepend to the link title.
|
||||
|
||||
@example {{< list-pages-in-section path=/methods/resources >}}
|
||||
@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude >}}
|
||||
@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo >}}
|
||||
*/}}
|
||||
|
||||
{{/* Initialize. */}}
|
||||
{{ $filter := or "" (.Get "filter" | lower) }}
|
||||
{{ $filterType := or (.Get "filterType") "none" | lower }}
|
||||
{{ $filteredPages := slice }}
|
||||
{{ $titlePrefix := or (.Get "titlePrefix") "" }}
|
||||
|
||||
{{/* Build slice of filtered pages. */}}
|
||||
{{ with $filter }}
|
||||
{{ with index site.Data.page_filters . }}
|
||||
{{ range . }}
|
||||
{{ with site.GetPage . }}
|
||||
{{ $filteredPages = $filteredPages | append . }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode was unable to find %q as specified in the page_filters data file. See %s" $.Name . $.Position }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode was unable to find the %q filter in the page_filters data file. See %s" $.Name . $.Position }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Render. */}}
|
||||
{{ with $sectionPath := .Get "path" }}
|
||||
{{ with site.GetPage . }}
|
||||
{{ with .RegularPages }}
|
||||
{{ range $page := .ByTitle }}
|
||||
{{ if or
|
||||
(and (eq $filterType "include") (in $filteredPages $page))
|
||||
(and (eq $filterType "exclude") (not (in $filteredPages $page)))
|
||||
(eq $filterType "none")
|
||||
}}
|
||||
{{ $linkTitle := .LinkTitle }}
|
||||
{{ with $titlePrefix }}
|
||||
{{ $linkTitle = printf "%s%s" . $linkTitle }}
|
||||
{{ end }}
|
||||
[{{ $linkTitle }}]({{ $page.RelPermalink }}){{/* Do not indent. */}}
|
||||
: {{ $page.Description }}{{/* Do not indent. */}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ warnf "The %q shortcode found no pages in the %q section. See %s" $.Name $sectionPath $.Position }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode was unable to find %q. See %s" $.Name $sectionPath $.Position }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode requires a 'path' parameter indicating the path to the section. See %s" $.Name $.Position }}
|
||||
{{ end }}
|
2
docs/layouts/_shortcodes/module-mounts-note.html
Normal file
2
docs/layouts/_shortcodes/module-mounts-note.html
Normal file
@@ -0,0 +1,2 @@
|
||||
For a more flexible approach to configuring this directory, consult the section
|
||||
on [module mounts](/configuration/module/#mounts).
|
64
docs/layouts/_shortcodes/new-in.html
Normal file
64
docs/layouts/_shortcodes/new-in.html
Normal file
@@ -0,0 +1,64 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders a callout or badge indicating the version in which a feature was added.
|
||||
|
||||
To render a callout, include descriptive text between the opening and closing
|
||||
tags. To render a badge,omit the descriptive text and call the shortcode with a
|
||||
self-closing tag.
|
||||
|
||||
When comparing the current version to the specified version, the "new in"
|
||||
button will be hidden if any of the following conditions is true:
|
||||
|
||||
- The major version difference exceeds the majorVersionDiffThreshold
|
||||
- The minor version difference exceeds the minorVersionDiffThreshold
|
||||
|
||||
@param {string} 0 The semantic version string, with or without a leading v.
|
||||
|
||||
@example {{< new-in 0.100.0 />}}
|
||||
|
||||
@example {{{< new-in 0.100.0 >}}
|
||||
Some descriptive text here.
|
||||
{{< /new-in >}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- $majorVersionDiffThreshold := 0 }}
|
||||
{{- $minorVersionDiffThreshold := 30 }}
|
||||
{{- $displayExpirationWarning := true }}
|
||||
|
||||
{{- with $version := .Get 0 | strings.TrimLeft "vV" }}
|
||||
{{- $majorVersionDiff := sub (index (split hugo.Version ".") 0 | int) (index (split $version ".") 0 | int) }}
|
||||
{{- $minorVersionDiff := sub (index (split hugo.Version ".") 1 | int) (index (split $version ".") 1 | int) }}
|
||||
{{- if or (gt $majorVersionDiff $majorVersionDiffThreshold) (gt $minorVersionDiff $minorVersionDiffThreshold) }}
|
||||
{{- if $displayExpirationWarning }}
|
||||
{{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}
|
||||
{{- with $.Inner }}
|
||||
{{- $inner := strings.TrimSpace . }}
|
||||
{{- $text := printf "New in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }}
|
||||
{{ partial "layouts/blocks/alert.html" (dict
|
||||
"color" "green"
|
||||
"icon" "exclamation"
|
||||
"text" $text
|
||||
)
|
||||
}}
|
||||
{{- else }}
|
||||
<span
|
||||
class="not-prose inline-flex items-center px-2 mr-1 rounded text-sm font-medium bg-green-200 dark:bg-green-400 fill-green-600">
|
||||
<svg class="mr-1.5 h-2 w-2" viewBox="0 0 8 8">
|
||||
<circle cx="4" cy="4" r="3" />
|
||||
</svg>
|
||||
<a
|
||||
class="text-green-800 dark:text-black hover:text-green-600 no-underline"
|
||||
href="{{ $href }}"
|
||||
target="_blank">
|
||||
New in
|
||||
v{{ $version }}
|
||||
</a>
|
||||
</span>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }}
|
||||
{{- end }}
|
71
docs/layouts/_shortcodes/per-lang-config-keys.html
Normal file
71
docs/layouts/_shortcodes/per-lang-config-keys.html
Normal file
@@ -0,0 +1,71 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders a responsive grid of the configuration keys that can be defined
|
||||
separately for each language.
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- $siteConfigKeys := slice
|
||||
(dict "baseURL" "/configuration/all/#baseurl")
|
||||
(dict "buildDrafts" "/configuration/all/#builddrafts")
|
||||
(dict "buildExpired" "/configuration/all/#buildexpired")
|
||||
(dict "buildFuture" "/configuration/all/#buildfuture")
|
||||
(dict "canonifyURLs" "/configuration/all/#canonifyurls")
|
||||
(dict "capitalizeListTitles" "/configuration/all/#capitalizelisttitles")
|
||||
(dict "contentDir" "/configuration/all/#contentdir")
|
||||
(dict "copyright" "/configuration/all/#copyright")
|
||||
(dict "disableAliases" "/configuration/all/#disablealiases")
|
||||
(dict "disableHugoGeneratorInject" "/configuration/all/#disablehugogeneratorinject")
|
||||
(dict "disableKinds" "/configuration/all/#disablekinds")
|
||||
(dict "disableLiveReload" "/configuration/all/#disablelivereload")
|
||||
(dict "disablePathToLower" "/configuration/all/#disablepathtolower")
|
||||
(dict "enableEmoji " "/configuration/all/#enableemoji")
|
||||
(dict "frontmatter" "/configuration/front-matter/")
|
||||
(dict "hasCJKLanguage" "/configuration/all/#hascjklanguage")
|
||||
(dict "languageCode" "/configuration/all/#languagecode")
|
||||
(dict "mainSections" "/configuration/all/#mainsections")
|
||||
(dict "markup" "/configuration/markup/")
|
||||
(dict "mediaTypes" "/configuration/media-types/")
|
||||
(dict "menus" "/configuration/menus/")
|
||||
(dict "outputFormats" "/configuration/output-formats")
|
||||
(dict "outputs" "/configuration/outputs/")
|
||||
(dict "page" "/configuration/page/")
|
||||
(dict "pagination" "/configuration/pagination/")
|
||||
(dict "params" "/configuration/params/")
|
||||
(dict "permalinks" "/configuration/permalinks/")
|
||||
(dict "pluralizeListTitles" "/configuration/all/#pluralizelisttitles")
|
||||
(dict "privacy" "/configuration/privacy/")
|
||||
(dict "refLinksErrorLevel" "/configuration/all/#reflinkserrorlevel")
|
||||
(dict "refLinksNotFoundURL" "/configuration/all/#reflinksnotfoundurl")
|
||||
(dict "related" "/configuration/related-content/")
|
||||
(dict "relativeURLs" "/configuration/all/#relativeurls")
|
||||
(dict "removePathAccents" "/configuration/all/#removepathaccents")
|
||||
(dict "renderSegments" "/configuration/all/#rendersegments")
|
||||
(dict "sectionPagesMenu" "/configuration/all/#sectionpagesmenu")
|
||||
(dict "security" "/configuration/security/")
|
||||
(dict "services" "/configuration/services/")
|
||||
(dict "sitemap" "/configuration/sitemap/")
|
||||
(dict "staticDir" "/configuration/all/#staticdir")
|
||||
(dict "summaryLength" "/configuration/all/#summarylength")
|
||||
(dict "taxonomies" "/configuration/taxonomies/")
|
||||
(dict "timeZone" "/configuration/all/#timezone")
|
||||
(dict "title" "/configuration/all/#title")
|
||||
(dict "titleCaseStyle" "/configuration/all/#titlecasestyle")
|
||||
}}
|
||||
|
||||
{{- $a := len $siteConfigKeys }}
|
||||
{{- $b := math.Ceil (div $a 2.) }}
|
||||
{{- $c := math.Ceil (div $a 3.) }}
|
||||
|
||||
|
||||
<div
|
||||
class="grid grid-flow-col grid-rows-{{ $a }} sm:grid-rows-{{ $b }} md:grid-rows-{{ $c }} gap-1">
|
||||
{{- range $siteConfigKeys }}
|
||||
{{ range $k, $v := . }}
|
||||
{{ $u := urls.Parse $v }}
|
||||
{{ if not (site.GetPage $u.Path) }}
|
||||
{{ errorf "The %q shorcode was unable to find %s. See %s." $.Name $u.Path $.Position }}
|
||||
{{ end }}
|
||||
<a href="{{ $v | relLangURL }}"><code>{{ $k }}</code></a>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
</div>
|
30
docs/layouts/_shortcodes/quick-reference.html
Normal file
30
docs/layouts/_shortcodes/quick-reference.html
Normal file
@@ -0,0 +1,30 @@
|
||||
{{- /*
|
||||
Renders the child sections of the given top-level section, listing each child's
|
||||
immediate descendants.
|
||||
|
||||
@param {string} section The top-level section to render.
|
||||
|
||||
@example {{% quick-reference section="/functions" %}}
|
||||
*/ -}}
|
||||
{{ $section := "" }}
|
||||
{{ with .Get "section" }}
|
||||
{{ $section = . }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcode requires a 'section' parameter. See %s" .Name .Position }}
|
||||
{{ end }}
|
||||
|
||||
{{ with site.GetPage $section }}
|
||||
{{ range .Sections }}
|
||||
## {{ .LinkTitle }}{{/* Do not indent. */}}
|
||||
{{ .Description }}{{/* Do not indent. */}}
|
||||
{{ .Content }}
|
||||
{{ with .Pages }}
|
||||
{{ range . }}
|
||||
[{{ .LinkTitle }}]({{ .RelPermalink }}){{/* Do not indent. */}}
|
||||
: {{ .Description }}{{/* Do not indent. */}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }}
|
||||
{{ end }}
|
45
docs/layouts/_shortcodes/root-configuration-keys.html
Normal file
45
docs/layouts/_shortcodes/root-configuration-keys.html
Normal file
@@ -0,0 +1,45 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{/*
|
||||
Renders a comma-separated list of links to the root key configuration pages.
|
||||
|
||||
@example {{< root-configuration-keys >}}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- /* Create scratch map of key:filename. */}}
|
||||
{{- $s := newScratch }}
|
||||
{{- range $k, $v := site.Data.docs.config }}
|
||||
{{- if or (reflect.IsMap .) (reflect.IsSlice .) }}
|
||||
{{- $s.Set $k ($k | humanize | anchorize) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/* Deprecated. */}}
|
||||
{{- $s.Delete "author" }}
|
||||
|
||||
{{/* Use mounts instead. */}}
|
||||
{{- $s.Delete "staticDir" }}
|
||||
{{- $s.Delete "ignoreFiles" }}
|
||||
|
||||
{{/* This key is "HTTPCache" not "httpCache". */}}
|
||||
{{- $s.Set "HTTPCache" "http-cache" }}
|
||||
|
||||
{{/* This key is "frontmatter" not "frontMatter" */}}
|
||||
{{- $s.Set "frontmatter" "front-matter" }}
|
||||
|
||||
{{/* The page title is "Related content" not "related". */}}
|
||||
{{- $s.Set "related" "related-content" }}
|
||||
|
||||
{{/* It can be configured as bool or map; we want to show map. */}}
|
||||
{{- $s.Set "uglyURLs" "ugly-urls" }}
|
||||
|
||||
{{- $links := slice }}
|
||||
{{- range $k, $v := $s.Values }}
|
||||
{{- $path := printf "/configuration/%s" $v }}
|
||||
{{- with site.GetPage $path }}
|
||||
{{- $links = $links | append (printf "<a href=%q><code>%s</code></a>" .RelPermalink $k) }}
|
||||
{{- else }}
|
||||
{{- errorf "The %q shortcode was unable to find the page %s. See %s." $.Name $path $.Position }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- delimit $links ", " ", and " | safeHTML -}}
|
70
docs/layouts/_shortcodes/syntax-highlighting-styles.html
Normal file
70
docs/layouts/_shortcodes/syntax-highlighting-styles.html
Normal file
@@ -0,0 +1,70 @@
|
||||
{{- /*
|
||||
Renders a gallery a Chroma syntax highlighting styles.
|
||||
|
||||
@example {{% syntax-highlighting-styles %}}
|
||||
*/ -}}
|
||||
{{- $examples := slice }}
|
||||
|
||||
{{- /* Example: css */}}
|
||||
{{- $example := dict "lang" "css" "code" `
|
||||
body {
|
||||
font-size: 16px; /* comment */
|
||||
}
|
||||
`}}
|
||||
{{- $examples = $examples | append $example }}
|
||||
|
||||
{{- /* Example: html */}}
|
||||
{{- $example = dict "lang" "html" "code" `
|
||||
<a href="/about.html">Example</a> <!-- comment -->
|
||||
`}}
|
||||
{{- $examples = $examples | append $example }}
|
||||
|
||||
{{- /* Example: go-html-template */}}
|
||||
{{- $example = dict "lang" "go-html-template" "code" `
|
||||
{{ with $.Page.Params.content }}
|
||||
{{ . | $.Page.RenderString }} {{/* comment */}}
|
||||
{{ end }}
|
||||
`}}
|
||||
{{- $examples = $examples | append $example }}
|
||||
|
||||
{{- /* Example: javascript */}}
|
||||
{{- $example = dict "lang" "javascript" "code" `
|
||||
if ([1,"one",2,"two"].includes(value)){
|
||||
console.log("Number is either 1 or 2."); // comment
|
||||
}
|
||||
`}}
|
||||
{{- $examples := $examples | append $example }}
|
||||
|
||||
{{- /* Example: markdown */}}
|
||||
{{- $example = dict "lang" "markdown" "code" `
|
||||
{{< figure src="kitten.jpg" >}}
|
||||
[example](https://example.org "An example") <!-- comment -->
|
||||
`}}
|
||||
{{- $examples := $examples | append $example }}
|
||||
|
||||
{{- /* Example: toml */}}
|
||||
{{- $example = dict "lang" "toml" "code" `
|
||||
[params]
|
||||
bool = true # comment
|
||||
string = 'foo'
|
||||
`}}
|
||||
{{- $examples := $examples | append $example }}
|
||||
|
||||
{{- /* Render */}}
|
||||
{{- with site.Data.docs.chroma.styles }}
|
||||
{{- range $style := . }}
|
||||
|
||||
### {{ $style }} {class="!mt-7 !mb-6"}{{/* Do not indent. */}}
|
||||
|
||||
{{- range $examples }}
|
||||
|
||||
{{ .lang }}{{/* Do not indent. */}}
|
||||
{class="text-sm !-mt-3 !-mb-5"}{{/* Do not indent. */}}
|
||||
|
||||
```{{ .lang }} {noClasses=true style="{{ $style }}"}{{/* Do not indent. */}}
|
||||
{{- .code | safeHTML -}}{{/* Do not indent. */}}
|
||||
```{{/* Do not indent. */}}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
Reference in New Issue
Block a user