Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -1,7 +1,28 @@
<dl>
{{ range .Site.Data.docs.chroma.lexers }}
<dt>{{ .Name }}</dt>
<dd>{{ with .Aliases }}{{ delimit . ", " }}{{ end }}</dd>
{{ end }}
</dl>
{{/* 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>

View File

@@ -1,19 +1,26 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
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] 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.
@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.
@returns {template.HTML}
*/}}
@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 := "" }}
{{- $dataKey := "" }}
{{- $copy := false }}
{{- $dataKey := "" }}
{{- $file := "" }}
{{- $fm := false }}
{{- $skipHeader := false }}
@@ -60,22 +67,26 @@
{{- else }}
{{- $code = $.Inner }}
{{- end }}
<div x-data class="shortcode-code not-prose relative p-0 mt-2 mb-4 sm:mb-8">
<svg
class="absolute right-2 top-0 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-8"
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
<use href="#icon--copy"></use>
</svg>
<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 }}
{{- with $file }}
<div
class="flex-none text-sm px-2 content-center border-b-1 border-gray-300 dark:border-gray-700"
aria-lbabel="Filename">
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) }}
{{- 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` . }}"
@@ -83,14 +94,14 @@
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>
<span class="select-none">
{{ . }}
</span>
</button>
{{ end }}
{{- end }}
</nav>
{{ if $code }}
{{ range $i, $lang := $langs }}
{{- 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 }}"
@@ -102,8 +113,8 @@
{{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }}
{{- end }}
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
{{- highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
</div>
{{ end }}
{{ end }}
{{- end }}
{{- end }}
</div>

View File

@@ -1,38 +0,0 @@
{{- $codeLang := or (.Get "lang") "" }}
<div
x-data
class="shortcode-code font-mono not-prose relative mt-6 mb-8 border-1 border-gray-200 dark:border-gray-800 bg-light dark:bg-dark">
{{ if (.Get "copy") }}
<svg
class="absolute right-2 top-2 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-6 h-6"
@click="$copy($refs.code)">
<use href="#icon--copy"></use>
</svg>
{{ end }}
{{- with .Get "file" -}}
{{- if not $codeLang }}
{{- $ext := strings.TrimPrefix "." (path.Ext .) }}
{{- $codeLang = cond (eq $ext "html") "go-html-template" $ext }}
{{- end }}
<div
class="san-serif text-sm inline-block leading-none pl-2 py-3 bg-gray-300 dark:bg-slate-700 dark: w-full select-none
">
{{ . }}
</div>
{{- end -}}
<div class="" x-ref="code">
{{ $inner := trim .Inner "\n" | safeHTML }}
{{ if .Get "nocode" }}
{{ $inner }}
{{ else }}
{{ with $codeLang }}
{{ highlight $inner . "" }}
{{ else }}
<pre class="overflow-x-auto p-2 w-[93%]"><code>{{ $inner }}</code>
</pre>
{{ end }}
{{ end }}
</div>
</div>

View File

@@ -9,31 +9,39 @@
{{ $fields := after 3 .Params }}
{{ $list := where $list $filter1 $filter2 $filter3 }}
<table class="table table-bordered">
<tr>
{{ range $fields }}
<th>{{ . }}</th>
{{ end }}
</tr>
{{ 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 }}
</table>
<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>

View File

@@ -4,30 +4,36 @@
{{ $fields := after 2 .Params }}
<table class="table table-bordered">
<tr>
{{ range $fields }}
{{ $s := . }}
{{ if eq $s "_key" }}
{{ $s = "Type" }}
{{ end }}
<th>{{ $s }}</th>
{{ end }}
</tr>
{{ 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 . }}
<div class="overflow-x-auto">
<table>
<thead>
<tr>
{{ range $fields }}
{{ $s := . }}
{{ if eq $s "_key" }}
{{ $s = "type" }}
{{ end }}
<th>{{ $s }}</th>
{{ end }}
<td>{{ $s }}</td>
</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 }}
</tr>
{{ end }}
</table>
</tbody>
</table>
</div>

View File

@@ -1,17 +1,29 @@
{{ $_hugo_config := `{ "version": 1 }` }}
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a callout indicating the version in which a feature was deprecated.
{{ with .Get 0 }}
{{ $version := printf "v%v" (strings.TrimLeft "vV" .) }}
{{ $href := printf "https://github.com/gohugoio/hugo/releases/tag/%s" $version }}
{{ $text := (printf `Deprecated in <a href="%s">%s</a>.
%s` $href $version $.Inner) | safeHTML }}
Include descriptive text between the opening and closing tags, or omit the
descriptive text and call the shortcode with a self-closing tag.
{{ partial "layouts/blocks/alert.html" (dict
"text" $text
"color" "orange"
"icon" "exclamation"
)
}}
{{ else }}
{{ errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }}
{{ end }}
@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 }}

View File

@@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders an absolute URL to the source code for an embedded template.
@@ -6,31 +7,20 @@ embedded_templates.toml file in the data directory.
@param {string} filename The embedded template's file name, excluding extension.
@returns template.HTML
@example {{% et robots.txt %}}
@example {{% et filename=robots.txt %}}
*/}}
{{- /* Get parameters. */}}
{{- $filename := "" -}}
{{- if .IsNamedParams -}}
{{- $filename = .Get "filename" -}}
{{- else -}}
{{- $filename = .Get 0 -}}
{{- end -}}
{{- /* Render. */}}
{{- with $filename -}}
{{- 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 -}}
*/ -}}
{{/* 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 -}}

View File

@@ -2,16 +2,14 @@
Renders the definition of the given glossary term.
@param {string} (.Get 0) The glossary term.
@returns {template.HTML}
@example {{% glossary-term float %}}
@example {{% glossary-term "floating point" %}}
*/}}
*/ -}}
{{- with .Get 0 }}
{{- $path := printf "/quick-reference/glossary/%s" (urlize .) }}
{{- with site.GetPage $path }}
{{ .RenderShortcodes }}&nbsp;{{/* Do not indent. Do not remove non-breaking space. */}}
{{ .RenderShortcodes }}{{/* Do not indent. */}}
{{- else }}
{{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }}
{{- end }}

View File

@@ -2,54 +2,52 @@
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 .Page.Fragments.
This allows the link render hook to verify links to glossary terms.
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 fragments rendered by this
least not right now. Instead, we want to link to the ids rendered by this
shortcode.
@returns {template.HTML}
@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) }}
{{- /* Build and render alphabetical index. */}}
{{- $m := dict }}
{{- range $p := .Pages.ByTitle }}
{{- $k := substr .Title 0 1 | strings.ToUpper }}
{{- if index $m $k }}
{{- continue }}
{{- end }}
{{- range $k, $v := $m }}
{{- $anchor := path.BaseName .Path | anchorize }}
{{- $m = merge $m (dict $k $anchor) }}
{{- end }}
{{- range $k, $v := $m }}
[{{ $k }}](#{{ $v }})&nbsp;{{/* Do not indent. */}}
{{- end }}
{{- end }}
{{- /* Render glossary terms. */}}
{{- range $p := .Pages.ByTitle }}
###### {{ .Title }}{{/* Do not indent. */}}
{{ .RenderShortcodes }}{{/* Do not indent. */}}
{{- with .Params.reference }}
{{- $destination := "" }}
{{- with $u := urls.Parse . }}
{{- if $u.IsAbs }}
{{- $destination = $u.String }}
{{/* 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 }}
{{- 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 }}
{{- errorf "The %q shortcode was unable to find the reference link %s: see %s" $.Name . $p.String }}
{{- end }}
{{- end -}}
&#32;See&nbsp;[details]({{ $destination }}).{{/* Do not indent. */}}
{{- end }}
{{- end }}
: See&nbsp;[details]({{ $destination }}).{{/* Do not indent. */}}
{{- end }}
{{ end }}
{{- else }}
{{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}}

View File

@@ -1,12 +0,0 @@
{{ $text := `
Most of the commands for **Hugo Modules** require a newer version (>= 1.18) of Go installed (see https://golang.org/dl/) and the relevant VCS client (e.g. Git, see https://git-scm.com/downloads/ ).
If you have an "older" site running on Netlify, you may have to set GO_VERSION to 1.19 or newer in your Environment settings.
For more information about Go Modules, see:
* https://go.dev/wiki/Modules
* https://blog.golang.org/using-go-modules
`
}}
{{ partial "layouts/blocks/alert.html" (dict "title" "Go Modules" "text" ($text | markdownify) "color" "orange" "icon" "exclamation") }}

View File

@@ -1,11 +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" }}
{{- $lang := or (.Get 0) "go" }}
{{- $opts := dict "hl_inline" true "noClasses" true }}
{{- transform.Highlight $code $lang $opts }}

View File

@@ -1,90 +1,85 @@
{{/* 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.
@returns {template.HTML}
@example {{< img src="zion-national-park.jpg" >}}
@example {{< img src="zion-national-park.jpg" alt="Zion National Park" >}}
@examples
@example {{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
>}}
{{< img src="zion-national-park.jpg" >}}
@example {{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="process"
filterArgs="resize 400x webp"
>}}
{{< img src="zion-national-park.jpg" alt="Zion National Park" >}}
@example {{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="colorize"
filterArgs="180,50,20"
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
>}}
@example {{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
example=true
>}}
{{< 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="grayscale"
example=true
exampleWidth=400
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="colorize"
filterArgs="180,50,20"
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
example=true
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
example=true
exampleWidth=400
>}}
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)
{{< img
src="images/examples/zion-national-park.jpg"
alt="Zion National Park"
filter="Text"
filterArgs="Zion National Park,25,250,56"
example=true
>}}
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
{{< img
src="images/examples/zion-national-park.jpg"
alt="Zion National Park"
filter="Padding"
filterArgs="20,50,20,50,#0705"
example=true
>}}
*/}}
@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 := "" }}
@@ -100,12 +95,12 @@ Renders the given image using the given filter, if any.
"fontSize" 64
"lineHeight" 1.2
"fontColor" "#ffffff"
"fontPath" "https://github.com/google/fonts/raw/main/ofl/lato/Lato-Regular.ttf"
"fontPath" "https://github.com/google/fonts/raw/refs/heads/main/ofl/lato/Lato-Regular.ttf"
}}
{{- /* Get and validate parameters. */}}
{{- with .Get "alt" }}
{{- $alt = .}}
{{- $alt = . }}
{{- end }}
{{- with .Get "src" }}
@@ -138,7 +133,7 @@ Renders the given image using the given filter, if any.
{{- if in (slice "false" false 0) (.Get "example") }}
{{- $example = false }}
{{- else if in (slice "true" true 1) (.Get "example")}}
{{- else if in (slice "true" true 1) (.Get "example") }}
{{- $example = true }}
{{- end }}
@@ -328,17 +323,22 @@ Renders the given image using the given filter, if any.
{{- end }}
{{- /* Render. */}}
{{- $class := "di va b--black-20" }}
{{- if eq $filter "mask" }}
{{- $class = "di va" }}
{{- end }}
{{- $class := "border-1 border-gray-300 dark:border-gray-500" }}
{{- if $example }}
<p>Original</p>
<img class="{{ $class}}" style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
<img
class="{{ $class }}"
src="{{ $i.RelPermalink }}"
alt="{{ $alt }}">
<p>Processed</p>
<img class="{{ $class }}" style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
<img
class="{{ $class }}"
src="{{ $fi.RelPermalink }}"
alt="{{ $alt }}">
{{- else -}}
<img class='di' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
<img
src="{{ $fi.RelPermalink }}"
alt="{{ $alt }}">
{{- end }}
{{- define "validate-arg-count" }}
@@ -387,5 +387,5 @@ Renders the given image using the given filter, if any.
{{- end }}
{{- end }}
{{- end }}
{{- return $r}}
{{- return $r }}
{{- end -}}

View File

@@ -1,37 +1,39 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders the given image using the given process specification.
@param {string} (positional parameter 0) The path to the image, relative to the current page. The image must be a page resource.
@param {string}} (positional parameter 1) The image processing 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.
@returns template.HTML
@example {{< imgproc "sunset.jpg" "resize 300x" />}}
*/}}
{{- with $.Get 0 }}
{{- with $i := $.Page.Resources.Get . }}
{{- with $spec := $.Get 1 }}
@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 style="padding: 0.25rem; margin: 2rem 0; background-color: #cccc">
<img style="max-width: 100%; width: auto; height: auto;" src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
<figcaption>
<small>
{{- with $.Inner }}
{{ . }}
{{- else }}
{{ $spec }}
{{- end }}
</small>
<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 positional parameter (1) containing the image processing specification. See %s" $.Name $.Position }}
{{- 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 positional parameter (0) indicating the image path, relative to the current page. See %s" $.Name $.Position }}
{{- 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 }}

View File

@@ -1,20 +1,19 @@
{{/* 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.
@returns template.HTML
@example {{% include "functions/_common/glob-patterns" %}}
*/}}
*/ -}}
{{/* prettier-ignore-end */ -}}
{{- with .Get 0 }}
{{- with or ($.Page.GetPage .) (site.GetPage .) }}
{{- .RenderShortcodes }}
{{- else }}
{{/* TODO1 make error */}}
{{- warnf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{- 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 }}

View File

@@ -9,88 +9,61 @@ 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.
The definition term elements (dt) have an id attribute derived from the title
of the page. This is probably unique, because pages of the same title in the
same section is unlikely.
If you render a complete list on a page, then call the shortcode again to
render a subset, you will generate duplicate element ids. In this case, set
omitElementIDs to true for the subset.
@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} [omitElementIDs=false] Whether to omit dt element ids.
@param {string} [titlePrefix=""] The string to prepend to the link title.
@returns template.HTML
@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 >}}
@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo omitElementIDs=true >}}
*/}}
{{- /* Initialize. */}}
{{- $filter := or "" (.Get "filter" | lower)}}
{{- $filterType := or (.Get "filterType") "none" | lower }}
{{- $filteredPages := slice }}
{{- $titlePrefix := or (.Get "titlePrefix") "" }}
{{- $omitElementIDs := false }}
{{/* Initialize. */}}
{{ $filter := or "" (.Get "filter" | lower) }}
{{ $filterType := or (.Get "filterType") "none" | lower }}
{{ $filteredPages := slice }}
{{ $titlePrefix := or (.Get "titlePrefix") "" }}
{{- /* Get boolean parameters. */}}
{{- if in (slice "false" false 0) (.Get "omitElementIDs") }}
{{- $omitElementIDs = false }}
{{- else if in (slice "true" true 1) (.Get "omitElementIDs")}}
{{- $omitElementIDs = true }}
{{- end }}
{{/* 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 }}
{{- /* 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 }}
<dl>
{{- range $page := .ByTitle }}
{{- if or
{{/* 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 }}
{{- $idAttribute := "" }}
{{- if not $omitElementIDs }}
{{- $id := path.Join .File.Dir .File.ContentBaseName | replaceRE `[\|/]` ":" | lower }}
{{- $idAttribute = printf " id=%q" $id }}
{{- end }}
<dt {{- $idAttribute | safeHTMLAttr }}><a href="{{ $page.RelPermalink }}">{{ $linkTitle }}</a></dt>
<dd>{{- $page.Description | $page.RenderString }}</dd>
{{- end }}
{{- end }}
</dl>
{{- 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 }}
{{ $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 }}

View File

@@ -1 +1,2 @@
Also see [Module Mounts Config](/hugo-modules/configuration/#module-configuration-mounts) for an alternative way to configure this directory.
For a more flexible approach to configuring this directory, consult the section
on [module mounts](/configuration/module/#mounts).

View File

@@ -1,31 +1,31 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a "new in" button indicating the version in which a feature was added.
Renders a callout or badge indicating the version in which a feature was added.
When comparing the current version to the specified version, the "new in"
button will be hidden if any of the following conditions is true:
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.
- The major version difference exceeds the majorVersionDiffThreshold
- The minor version difference exceeds the minorVersionDiffThreshold
When comparing the current version to the specified version, the "new in"
button will be hidden if any of the following conditions is true:
@param {string} version The semantic version string, with or without a leading v.
@returns {template.HTML}
- The major version difference exceeds the majorVersionDiffThreshold
- The minor version difference exceeds the minorVersionDiffThreshold
@examples {{< new-in 0.100.0 /
>}}
@param {string} 0 The semantic version string, with or without a leading v.
{{< new-in 0.100.0 >}}
Some descriptive text here.
{{< /new-in >}}
*/}}
{{ $_hugo_config := `{ "version": 1 }` }}
@example {{< new-in 0.100.0 />}}
{{- /* Set defaults. */}}
@example {{{< new-in 0.100.0 >}}
Some descriptive text here.
{{< /new-in >}}
*/ -}}
{{/* prettier-ignore-end */ -}}
{{- $majorVersionDiffThreshold := 0 }}
{{- $minorVersionDiffThreshold := 30 }}
{{- $displayExpirationWarning := true }}
{{- /* Render. */}}
{{- with $version := .Get 0 | strings.TrimPrefix "v" }}
{{- 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) }}
@@ -35,14 +35,12 @@ Some descriptive text here.
{{- else }}
{{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}
{{- with $.Inner }}
{{ $text := printf `<p class="fon-semibold">New in <a href=%q>v%s</a>.</p>%s`
$href $version (. | $.Page.RenderString (dict "display" "block"))
}}
{{- $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
"text" ($text | safeHTML)
"color" "green"
"icon" "exclamation"
"text" $text
)
}}
{{- else }}
@@ -62,5 +60,5 @@ Some descriptive text here.
{{- end }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a positional parameter (version). See %s" .Name .Position }}
{{- end -}}
{{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }}
{{- end }}

View File

@@ -1,7 +0,0 @@
{{ $_hugo_config := `{ "version": 1 }` }}
{{ partial "layouts/blocks/alert.html" (dict
"text" .Inner
"color" "blue"
"icon" "exclamation"
)
}}

View 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>

View File

@@ -1,37 +1,28 @@
{{/*
Renders the child sections of the given top-level section, listing each child's immediate descendants.
{{- /*
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.
@returns template.HTML
@example {{% quick-reference section="functions" %}}
*/}}
@example {{% quick-reference section="/functions" %}}
*/ -}}
{{ $section := "" }}
{{ with .Get "section" }}
{{ $section = . }}
{{ else }}
{{ errorf "The %q shortcodes requires a 'section' parameter. See %s" .Name .Position }}
{{ errorf "The %q shortcode requires a 'section' parameter. See %s" .Name .Position }}
{{ end }}
{{/* Do not change the markdown indentation, and do not remove blank lines. */}}
{{ with site.GetPage $section }}
{{ range .Sections }}
## {{ .LinkTitle }}
{{ .RawContent }}
{{ range .Pages }}
{{ $aliases := "" }}
{{ if eq .Section "functions" }}
{{ with .Params.action.aliases }}
{{ $aliases = delimit . " or " }}
{{ end }}
## {{ .LinkTitle }}{{/* Do not indent. */}}
{{ .Description }}{{/* Do not indent. */}}
{{ .Content }}
{{ with .Pages }}
{{ range . }}
[{{ .LinkTitle }}]({{ .RelPermalink }}){{/* Do not indent. */}}
: {{ .Description }}{{/* Do not indent. */}}
{{ end }}
[{{ .LinkTitle }}]({{ .RelPermalink }}) {{ with $aliases }}({{ . }}){{ end }}
: {{ .Description }}
{{ end }}
{{ end }}
{{ else }}

View File

@@ -1 +0,0 @@
TODO readfile.html

View 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 -}}

View 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 }}