mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-08-03 20:49:41 -04:00
Vendor theme
This commit is contained in:
parent
6b0a9b75de
commit
0ee3ff44f7
@ -1,4 +1,4 @@
|
|||||||
// Grab any element that has the 'js-toggle' class and add an event listner for the toggleClass function
|
// Grab any element that has the 'js-toggle' class and add an event listener for the toggleClass function
|
||||||
var toggleBtns = document.getElementsByClassName('js-toggle')
|
var toggleBtns = document.getElementsByClassName('js-toggle')
|
||||||
for (var i = 0; i < toggleBtns.length; i++) {
|
for (var i = 0; i < toggleBtns.length; i++) {
|
||||||
toggleBtns[i].addEventListener('click', toggleClass, false)
|
toggleBtns[i].addEventListener('click', toggleClass, false)
|
||||||
|
@ -201,7 +201,7 @@ either of these shortcodes in conjunction with this render hook.
|
|||||||
Validates the fragment portion of a link destination.
|
Validates the fragment portion of a link destination.
|
||||||
|
|
||||||
@context {string} contentPath The page containing the link.
|
@context {string} contentPath The page containing the link.
|
||||||
@context {srting} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
|
@context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
|
||||||
@context {page} page The page corresponding to the link destination
|
@context {page} page The page corresponding to the link destination
|
||||||
@context {struct} parsedURL The link destination parsed by urls.Parse.
|
@context {struct} parsedURL The link destination parsed by urls.Parse.
|
||||||
@context {string} renderHookName The name of the render hook.
|
@context {string} renderHookName The name of the render hook.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{{ $href := printf "https://github.com/gohugoio/hugo/releases/tag/%s" $version }}
|
{{ $href := printf "https://github.com/gohugoio/hugo/releases/tag/%s" $version }}
|
||||||
<aside>
|
<aside>
|
||||||
<div class="admonition-content bl bw2 b--dark-red" >
|
<div class="admonition-content bl bw2 b--dark-red" >
|
||||||
<p>Deprecated in <a href="{{ $href }}">{{ $version }}</a></p>
|
<p>Deprecated in <a href="{{ $href }}">{{ $version }}</a>.</p>
|
||||||
{{ $.Inner }}
|
{{ $.Inner }}
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
@ -100,7 +100,7 @@ Renders the given image using the given filter, if any.
|
|||||||
"fontSize" 64
|
"fontSize" 64
|
||||||
"lineHeight" 1.2
|
"lineHeight" 1.2
|
||||||
"fontColor" "#ffffff"
|
"fontColor" "#ffffff"
|
||||||
"fontPath" "https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Regular.ttf"
|
"fontPath" "https://github.com/google/fonts/raw/main/ofl/lato/Lato-Regular.ttf"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{- /* Get and validate parameters. */}}
|
{{- /* Get and validate parameters. */}}
|
||||||
@ -119,9 +119,10 @@ Renders the given image using the given filter, if any.
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- $validFilters := slice
|
{{- $validFilters := slice
|
||||||
"brightness" "colorbalance" "colorize" "contrast" "gamma" "gaussianblur"
|
"autoorient" "brightness" "colorbalance" "colorize" "contrast" "gamma"
|
||||||
"grayscale" "hue" "invert" "none" "opacity" "overlay" "padding" "pixelate"
|
"gaussianblur" "grayscale" "hue" "invert" "none" "opacity" "overlay"
|
||||||
"process" "saturation" "sepia" "sigmoid" "text" "unsharpmask"
|
"padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text"
|
||||||
|
"unsharpmask"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{- with $filter }}
|
{{- with $filter }}
|
||||||
@ -157,7 +158,11 @@ Renders the given image using the given filter, if any.
|
|||||||
{{- /* Create filter. */}}
|
{{- /* Create filter. */}}
|
||||||
{{- $f := "" }}
|
{{- $f := "" }}
|
||||||
{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }}
|
{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }}
|
||||||
{{- if eq $filter "brightness" }}
|
{{- 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) }}
|
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
|
||||||
{{- template "validate-arg-count" $ctx }}
|
{{- template "validate-arg-count" $ctx }}
|
||||||
{{- $filterArgs = apply $filterArgs "float" "." }}
|
{{- $filterArgs = apply $filterArgs "float" "." }}
|
||||||
|
@ -3,7 +3,7 @@ Renders the page using the RenderShortcode method on the Page object.
|
|||||||
|
|
||||||
You must call this shortcode using the {{% %}} notation.
|
You must call this shortcode using the {{% %}} notation.
|
||||||
|
|
||||||
@param {string} (postional parameter 0) The path to the page, relative to the content directory.
|
@param {string} (positional parameter 0) The path to the page, relative to the content directory.
|
||||||
@returns template.HTML
|
@returns template.HTML
|
||||||
|
|
||||||
@example {{% include "functions/_common/glob-patterns" %}}
|
@example {{% include "functions/_common/glob-patterns" %}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{- /*
|
{{- /*
|
||||||
Renders a desciption list of the pages in the given section.
|
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,
|
Render a subset of the pages in the section by specifying a predefined filter,
|
||||||
and whether to include those pages.
|
and whether to include those pages.
|
||||||
|
@ -1,13 +1,36 @@
|
|||||||
{{ $version := .Get 0 }}
|
{{- /*
|
||||||
{{ if not $version }}
|
Renders a "new in" button indicating the version in which a feature was added.
|
||||||
{{ errorf "Missing version in new-in shortcode " }}
|
|
||||||
{{ end }}
|
When comparing the current version to the specified version, the "new in"
|
||||||
{{ $version = $version | strings.TrimPrefix "v" }}
|
button will be hidden if any of the following conditions is true:
|
||||||
<button
|
|
||||||
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 px-4 border border-gray-400 rounded shadow">
|
- The major version difference exceeds the majorVersionDiffThreshold
|
||||||
<a
|
- The minor version difference exceeds the minorVersionDiffThreshold
|
||||||
href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}"
|
|
||||||
target="_blank"
|
@param {string} version The semantic version string, with or without a leading v.
|
||||||
>New in v{{ $version }}</a
|
@returns {template.HTML}
|
||||||
>
|
|
||||||
</button>
|
@example {{< new-in 0.100.0 >}}
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- /* Set defaults. */}}
|
||||||
|
{{- $majorVersionDiffThreshold := 0 }}
|
||||||
|
{{- $minorVersionDiffThreshold := 30 }}
|
||||||
|
{{- $displayExpirationWarning := true }}
|
||||||
|
|
||||||
|
{{- /* Render. */}}
|
||||||
|
{{- with $version := .Get 0 | strings.TrimPrefix "v" }}
|
||||||
|
{{- $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 }}
|
||||||
|
<button class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 px-4 border border-gray-400 rounded shadow">
|
||||||
|
<a href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}">New in v{{ $version }}</a>
|
||||||
|
</button>
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- errorf "The %q shortcode requires a positional parameter (version). See %s" .Name .Position }}
|
||||||
|
{{- end -}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{{/*
|
{{/*
|
||||||
Renders the child sections of the given top-level section, listing each childs'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.
|
@param {string} section The top-level section to render.
|
||||||
@returns template.HTML
|
@returns template.HTML
|
||||||
@ -11,7 +11,7 @@ Renders the child sections of the given top-level section, listing each childs's
|
|||||||
{{ with .Get "section" }}
|
{{ with .Get "section" }}
|
||||||
{{ $section = . }}
|
{{ $section = . }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "The %q shortcodes requires a 'section' parameter. See %s" .Name .Postion }}
|
{{ errorf "The %q shortcodes requires a 'section' parameter. See %s" .Name .Position }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* Do not change the markdown indentation, and do not remove blank lines. */}}
|
{{/* Do not change the markdown indentation, and do not remove blank lines. */}}
|
||||||
@ -24,7 +24,9 @@ Renders the child sections of the given top-level section, listing each childs's
|
|||||||
{{ range .Pages }}
|
{{ range .Pages }}
|
||||||
{{ $aliases := "" }}
|
{{ $aliases := "" }}
|
||||||
{{ if eq .Section "functions" }}
|
{{ if eq .Section "functions" }}
|
||||||
{{ $aliases = delimit .Params.action.aliases " or " }}
|
{{ with .Params.action.aliases }}
|
||||||
|
{{ $aliases = delimit . " or " }}
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
[{{ .LinkTitle }}]({{ .RelPermalink }}) {{ with $aliases }}({{ . }}){{ end }}
|
[{{ .LinkTitle }}]({{ .RelPermalink }}) {{ with $aliases }}({{ . }}){{ end }}
|
||||||
@ -33,5 +35,5 @@ Renders the child sections of the given top-level section, listing each childs's
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Postion }}
|
{{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -1 +1 @@
|
|||||||
# github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e
|
# github.com/gohugoio/gohugoioTheme v0.0.0-20240108005931-638ffe386bd2
|
||||||
|
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module github.com/gohugoio/hugoDocs
|
|||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e // indirect
|
require github.com/gohugoio/gohugoioTheme v0.0.0-20240108005931-638ffe386bd2 // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -1,2 +1,2 @@
|
|||||||
github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e h1:X4OxWNt7weGfmRHBAQWW1gsdZBd3V/6DJMNhrYS9ALE=
|
github.com/gohugoio/gohugoioTheme v0.0.0-20240108005931-638ffe386bd2 h1:wa2rkKQnFxJK0czyiCiKgJZZ9fQQlzn1iFsuKryffHE=
|
||||||
github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM=
|
github.com/gohugoio/gohugoioTheme v0.0.0-20240108005931-638ffe386bd2/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM=
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
|
||||||
|
|
||||||
{{ with .Get 0 }}
|
|
||||||
{{ $version := printf "v%v" (strings.TrimLeft "vV" .) }}
|
|
||||||
{{ $href := printf "https://github.com/gohugoio/hugo/releases/tag/%s" $version }}
|
|
||||||
<aside>
|
|
||||||
<div class="admonition-content bl bw2 b--dark-red" >
|
|
||||||
<p>Deprecated in <a href="{{ $href }}">{{ $version }}</a>.</p>
|
|
||||||
{{ $.Inner }}
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
{{ else }}
|
|
||||||
{{ errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }}
|
|
||||||
{{ end }}
|
|
@ -1,379 +0,0 @@
|
|||||||
{{- /*
|
|
||||||
Renders the given image using the given filter, if any.
|
|
||||||
|
|
||||||
@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}
|
|
||||||
|
|
||||||
@examples
|
|
||||||
|
|
||||||
{{< img src="zion-national-park.jpg" >}}
|
|
||||||
|
|
||||||
{{< img src="zion-national-park.jpg" alt="Zion National Park" >}}
|
|
||||||
|
|
||||||
{{< img
|
|
||||||
src="zion-national-park.jpg"
|
|
||||||
alt="Zion National Park"
|
|
||||||
filter="grayscale"
|
|
||||||
>}}
|
|
||||||
|
|
||||||
{{< 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"
|
|
||||||
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
|
|
||||||
>}}
|
|
||||||
|
|
||||||
*/}}
|
|
||||||
|
|
||||||
{{- /* 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/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" "gamma"
|
|
||||||
"gaussianblur" "grayscale" "hue" "invert" "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 "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 "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. */}}
|
|
||||||
{{- if $example }}
|
|
||||||
<p>Original</p>
|
|
||||||
<img class='di ba b--black-20' style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
|
|
||||||
<p>Processed</p>
|
|
||||||
<img class='di ba b--black-20' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
|
|
||||||
{{- else -}}
|
|
||||||
<img class='di' style="width: initial;" 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 resources.GetRemote $u.String }}
|
|
||||||
{{- with .Err }}
|
|
||||||
{{- errorf "%s" }}
|
|
||||||
{{- else }}
|
|
||||||
{{- /* This is a remote resource. */}}
|
|
||||||
{{- $r = . }}
|
|
||||||
{{- end }}
|
|
||||||
{{- else }}
|
|
||||||
{{- errorf $msg $.name $u.String $.position }}
|
|
||||||
{{- 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 -}}
|
|
@ -1,36 +0,0 @@
|
|||||||
{{- /*
|
|
||||||
Renders a "new in" button 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:
|
|
||||||
|
|
||||||
- The major version difference exceeds the majorVersionDiffThreshold
|
|
||||||
- The minor version difference exceeds the minorVersionDiffThreshold
|
|
||||||
|
|
||||||
@param {string} version The semantic version string, with or without a leading v.
|
|
||||||
@returns {template.HTML}
|
|
||||||
|
|
||||||
@example {{< new-in 0.100.0 >}}
|
|
||||||
*/}}
|
|
||||||
|
|
||||||
{{- /* Set defaults. */}}
|
|
||||||
{{- $majorVersionDiffThreshold := 0 }}
|
|
||||||
{{- $minorVersionDiffThreshold := 30 }}
|
|
||||||
{{- $displayExpirationWarning := true }}
|
|
||||||
|
|
||||||
{{- /* Render. */}}
|
|
||||||
{{- with $version := .Get 0 | strings.TrimPrefix "v" }}
|
|
||||||
{{- $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 }}
|
|
||||||
<button class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 px-4 border border-gray-400 rounded shadow">
|
|
||||||
<a href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}">New in v{{ $version }}</a>
|
|
||||||
</button>
|
|
||||||
{{- end }}
|
|
||||||
{{- else }}
|
|
||||||
{{- errorf "The %q shortcode requires a positional parameter (version). See %s" .Name .Position }}
|
|
||||||
{{- end -}}
|
|
@ -1,39 +0,0 @@
|
|||||||
{{/*
|
|
||||||
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" %}}
|
|
||||||
*/}}
|
|
||||||
|
|
||||||
{{ $section := "" }}
|
|
||||||
{{ with .Get "section" }}
|
|
||||||
{{ $section = . }}
|
|
||||||
{{ else }}
|
|
||||||
{{ errorf "The %q shortcodes 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 }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
[{{ .LinkTitle }}]({{ .RelPermalink }}) {{ with $aliases }}({{ . }}){{ end }}
|
|
||||||
: {{ .Description }}
|
|
||||||
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
|
||||||
{{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }}
|
|
||||||
{{ end }}
|
|
Loading…
x
Reference in New Issue
Block a user