Update docs for v0.141.0

Closes #2808
This commit is contained in:
Joe Mooring 2025-01-05 11:08:28 -08:00 committed by Bjørn Erik Pedersen
parent a0a442d621
commit 575d603450
30 changed files with 787 additions and 932 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -39,11 +39,11 @@ respectDoNotTrack = false
[privacy.instagram]
disable = false
simple = false
[privacy.twitter]
[privacy.vimeo]
disable = false
enableDNT = false
simple = false
[privacy.vimeo]
[privacy.x]
disable = false
enableDNT = false
simple = false
@ -64,10 +64,10 @@ disable = true
disable = true
[privacy.instagram]
disable = true
[privacy.twitter]
disable = true
[privacy.vimeo]
disable = true
[privacy.x]
disable = true
[privacy.youtube]
disable = true
{{< /code-toggle >}}
@ -92,19 +92,19 @@ simple
disableInlineCSS = true
{{< /code-toggle >}}
### Twitter
### X
enableDNT
: Enabling this for the twitter/tweet shortcode, the tweet and its embedded page on your site are not used for purposes that include personalized suggestions and personalized ads.
: Enabling this for the x shortcode, the post and its embedded page on your site are not used for purposes that include personalized suggestions and personalized ads.
simple
: If simple mode is enabled, a static and no-JS version of a tweet will be built.
: If simple mode is enabled, a static and no-JS version of a post will be built.
**Note:** If you use the _simple mode_ for Twitter, you may want to disable the inline styles provided by Hugo:
**Note:** If you use the _simple mode_ for X, you may want to disable the inline styles provided by Hugo:
{{< code-toggle file=hugo >}}
[services]
[services.twitter]
[services.x]
disableInlineCSS = true
{{< /code-toggle >}}

View File

@ -72,7 +72,6 @@ hugo [flags]
* [hugo completion](/commands/hugo_completion/) - Generate the autocompletion script for the specified shell
* [hugo config](/commands/hugo_config/) - Display site configuration
* [hugo convert](/commands/hugo_convert/) - Convert front matter to another format
* [hugo deploy](/commands/hugo_deploy/) - Deploy your site to a cloud provider
* [hugo env](/commands/hugo_env/) - Display version and environment info
* [hugo gen](/commands/hugo_gen/) - Generate documentation and syntax highlighting styles
* [hugo import](/commands/hugo_import/) - Import a site from another system

View File

@ -193,14 +193,14 @@ Step 3
{{/* Get remote data. */}}
{{ $data := dict }}
{{ $url := "https://gohugo.io/shared/examples/data/books.json" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Unable to get remote resource %s: %s" $url . }}
{{ else }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{/* Add pages and page resources. */}}
@ -223,10 +223,10 @@ Step 3
{{/* Add page resource. */}}
{{ $item := . }}
{{ with $url := $item.cover }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Unable to get remote resource %s: %s" $url . }}
{{ else }}
{{ else with .Value }}
{{ $content := dict "mediaType" .MediaType.Type "value" .Content }}
{{ $params := dict "alt" $item.title }}
{{ $resource := dict
@ -235,9 +235,9 @@ Step 3
"path" (printf "%s/cover.%s" $item.title .MediaType.SubType)
}}
{{ $.AddResource $resource }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %s" $url }}
{{ end }}
{{ end }}

View File

@ -88,15 +88,15 @@ Example 3: A more concise way to skip image rendering if the resource is not fou
Example 4: Skips rendering if there's problem accessing a remote resource.
```go-html-template
{{ $u := "https://gohugo.io/img/hugo-logo.png" }}
{{ with resources.GetRemote $u }}
{{ $url := "https://gohugo.io/img/hugo-logo.png" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $u }}
{{ end }}
```

View File

@ -157,22 +157,3 @@ pattern
toLower
: (`bool`) See above.
## Performance considerations
**Fast is Hugo's middle name** and we would not have released this feature had it not been blistering fast.
This feature has been in the back log and requested by many for a long time. The development got this recent kick start from this Twitter thread:
{{< tweet user="scott_lowe" id="898398437527363585" >}}
Scott S. Lowe removed the "Related Content" section built using the `intersect` template function on tags, and the build time dropped from 30 seconds to less than 2 seconds on his 1700 content page sized blog.
He should now be able to add an improved version of that "Related Content" section without giving up the fast live-reloads. But it's worth noting that:
* If you don't use any of the `Related` methods, you will not use the Relate Content feature, and performance will be the same as before.
* Calling `.RegularPages.Related` etc. will create one inverted index, also sometimes named posting list, that will be reused for any lookups in that same page collection. Doing that in addition to, as an example, calling `.Pages.Related` will work as expected, but will create one additional inverted index. This should still be very fast, but worth having in mind, especially for bigger sites.
{{% note %}}
We currently do not index **Page content**. We thought we would release something that will make most people happy before we start solving [Sherlock's last case](https://github.com/joearms/sherlock).
{{% /note %}}

View File

@ -498,8 +498,6 @@ Rendered:
{{% note %}}
To override Hugo's embedded `twitter` shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes directory.
You may call the `twitter` shortcode by using its `tweet` alias.
[source code]: {{% eturl twitter %}}
{{% /note %}}

View File

@ -134,16 +134,16 @@ Consider using the [`resources.GetRemote`] function with [`transform.Unmarshal`]
```go-html-template
{{ $data := dict }}
{{ $u := "https://example.org/pets.csv" }}
{{ with resources.GetRemote $u }}
{{ $url := "https://example.org/pets.csv" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $opts := dict "delimiter" "," }}
{{ $data = . | transform.Unmarshal $opts }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $u }}
{{ end }}
```

View File

@ -137,15 +137,15 @@ Consider using the [`resources.GetRemote`] function with [`transform.Unmarshal`]
```go-html-template
{{ $data := dict }}
{{ $u := "https://example.org/books.json" }}
{{ with resources.GetRemote $u }}
{{ $url := "https://example.org/books.json" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $u }}
{{ end }}
```

View File

@ -25,16 +25,16 @@ https://api.github.com/repos/gohugoio/hugo/readme
To retrieve and render the content:
```go-html-template
{{ $u := "https://api.github.com/repos/gohugoio/hugo/readme" }}
{{ with resources.GetRemote $u }}
{{ $url := "https://api.github.com/repos/gohugoio/hugo/readme" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value}}
{{ with . | transform.Unmarshal }}
{{ .content | base64Decode | markdownify }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $u }}
{{ end }}
```

View File

@ -13,7 +13,7 @@ action:
toc: true
---
The `return` statement is a custom addition to Go's [text/template] package. Used within partial templates, the `return` statement terminates template execution and returns the given value, if any.
The `return` statement is a non-standard extension to Go's [text/template package]. Used within partial templates, the `return` statement terminates template execution and returns the given value, if any.
The returned value may be of any data type including, but not limited to, [`bool`], [`float`], [`int`], [`map`], [`resource`], [`slice`], and [`string`].

View File

@ -0,0 +1,110 @@
---
title: try
description: Returns a TryValue object after evaluating the given expression.
categories: []
keywords: []
action:
aliases: []
related: []
returnType: TryValue
signatures: ['try EXPRESSION']
toc: true
---
{{< new-in 0.141.0 >}}
The `try` statement is a non-standard extension to Go's [text/template] package. It introduces a mechanism for handling errors within templates, mimicking the `try-catch` constructs found in other programming languages.
[text/template]: https://pkg.go.dev/text/template
## Methods
The `TryValue` object encapsulates the result of evaluating the expression, and provides two methods:
Err
: (`string`) Returns a string representation of the error thrown by the expression, if an error occurred, or returns `nil` if the expression evaluated without errors.
Value
: (`any`) Returns the result of the expression if the evaluation was successful, or returns `nil` if an error occurred while evaluating the expression.
## Explanation
By way of example, let's divide a number by zero:
```go-html-template
{{ $x := 1 }}
{{ $y := 0 }}
{{ $result := div $x $y }}
{{ printf "%v divided by %v equals %v" $x $y .Value }}
```
As expected, the example above throws an error and fails the build:
```terminfo
Error: error calling div: can't divide the value by 0
```
Instead of failing the build, we can catch the error and emit a warning:
```go-html-template
{{ $x := 1 }}
{{ $y := 0 }}
{{ with try (div $x $y) }}
{{ with .Err }}
{{ warnf "%s" . }}
{{ else }}
{{ printf "%v divided by %v equals %v" $x $y .Value }}
{{ end }}
{{ end }}
```
The error thrown by the expression is logged to the console as a warning:
```terminfo
WARN error calling div: can't divide the value by 0
```
Now let's change the arguments to avoid dividing by zero:
```go-html-template
{{ $x := 42 }}
{{ $y := 6 }}
{{ with try (div $x $y) }}
{{ with .Err }}
{{ warnf "%s" . }}
{{ else }}
{{ printf "%v divided by %v equals %v" $x $y .Value }}
{{ end }}
{{ end }}
```
Hugo renders the above to:
```html
42 divided by 6 equals 7
```
## Example
Error handling is essential when using the [`resources.GetRemote`] function to capture remote resources such as data or images. When calling this function, if the HTTP request fails, Hugo will fail the build.
[`resources.GetRemote`]: /functions/resources/getremote/
Instead of failing the build, we can catch the error and emit a warning:
```go-html-template
{{ $url := "https://broken-example.org/images/a.jpg" }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ warnf "%s" . }}
{{ else with .Value }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
```
{{% note %}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemote` returns nil.
{{% /note %}}

View File

@ -0,0 +1,45 @@
---
title: images.Mask
description: Returns an image filter that applies a mask to the source image.
categories: []
keywords: []
action:
aliases: []
related:
- functions/images/Filter
- methods/resource/Filter
returnType: images.filter
signatures: [images.Mask RESOURCE]
toc: true
---
{{< new-in 0.141.0 >}}
The `images.Mask` filter applies a mask to an image. Black pixels in the mask make the corresponding areas of the base image transparent, while white pixels keep them opaque. Color images are converted to grayscale for masking purposes. The mask is automatically resized to match the dimensions of the base image.
## Usage
Create the filter:
```go-html-template
{{ $filter := images.Mak "images/mask.png" }}
```
{{% include "functions/images/_common/apply-image-filter.md" %}}
## Example
Mask
{{< img
src="images/examples/mask.png"
example=false
>}}
{{< img
src="images/examples/zion-national-park.jpg"
alt="Zion National Park"
filter="mask"
filterArgs="images/examples/mask.png"
example=true
>}}

View File

@ -52,14 +52,14 @@ Capture the font as a resource:
```go-html-template
{{ $font := "" }}
{{ $path := "https://github.com/google/fonts/raw/main/ofl/lato/Lato-Regular.ttf" }}
{{ with resources.GetRemote $path }}
{{ with try (resources.GetRemote $path) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $font = . }}
{{ else }}
{{ errorf "Unable to get resource %q" $path }}
{{ end }}
{{ else }}
{{ errorf "Unable to get resource %q" $path }}
{{ end }}
```

View File

@ -22,14 +22,14 @@ For example, to work with a remote [OpenAPI] definition:
```go-html-template
{{ $url := "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json" }}
{{ $api := "" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $api = . | openapi3.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```

View File

@ -20,14 +20,14 @@ toc: true
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@ -75,14 +75,14 @@ When retrieving remote data, use the [`transform.Unmarshal`] function to [unmars
```go-html-template
{{ $data := dict }}
{{ $url := "https://example.org/books.json" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@ -98,24 +98,24 @@ In these cases, pass the resource `Content` through the `transform.Unmarshal` fu
## Error handling
The [`Err`] method on a resource returned by the `resources.GetRemote` function returns an error message if the HTTP request fails, else nil. If you do not handle the error yourself, Hugo will fail the build.
Use the [`try`] statement to capture HTTP request errors. If you do not handle the error yourself, Hugo will fail the build.
[`Err`]: /methods/resource/err/
[`try`]: /functions/go-template/try
{{% note %}}
Hugo does not classify an HTTP response with status code 404 as an error. In this case the function returns nil.
Hugo does not classify an HTTP response with status code 404 as an error. In this case `resources.GetRemtoe`returns nil.
{{% /note %}}
```go-html-template
{{ $url := "https://broken-example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@ -123,14 +123,14 @@ To log an error as a warning instead of an error:
```go-html-template
{{ $url := "https://broken-example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ warnf "%s" . }}
{{ else }}
{{ else with .Value }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
{{ warnf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@ -142,10 +142,10 @@ The [`Data`] method on a resource returned by the `resources.GetRemote` function
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ with .Data }}
{{ .ContentLength }} → 42764
{{ .ContentType }} → image/jpeg
@ -153,9 +153,9 @@ The [`Data`] method on a resource returned by the `resources.GetRemote` function
{{ .StatusCode }} → 200
{{ .TransferEncoding }} → []
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```

View File

@ -97,11 +97,11 @@ There are 3 ways to handle errors from KaTeX:
1. Set the `throwOnError` option to `false` to make KaTeX render the expression as an error instead of throwing an error. See [options](#options).
{{< code file=layouts/_default/_markup/render-passthrough-inline.html copy=true >}}
{{ with transform.ToMath .Inner }}
{{ with try (transform.ToMath .Inner) }}
{{ with .Err }}
{{ errorf "Failed to render KaTeX: %q. See %s" . $.Position }}
{{ else }}
{{ . }}
{{ .Value }}
{{ end }}
{{ end }}
{{- /* chomp trailing newline */ -}}

View File

@ -97,14 +97,14 @@ A remote resource is a file on a remote server, accessible via HTTP or HTTPS.
```go-html-template
{{ $data := dict }}
{{ $url := "https://example.org/books.json" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ range where $data "author" "Victor Hugo" }}
@ -175,14 +175,14 @@ Get the remote data:
```go-html-template
{{ $data := dict }}
{{ $url := "https://example.org/books/index.xml" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```

View File

@ -266,6 +266,9 @@ To remain consistent and prevent unexpected behavior, do not mix these strategie
(`string`) The directory from where Hugo reads data files. Default is `data`. {{% module-mounts-note %}}
###### defaultOutputFormat
(`string`) The default output format for the site. If unspecified, the first available format in the defined order (by weight, then alphabetically) will be used.
###### defaultContentLanguage
(`string`) Content without language indicator will default to this language. Default is `en`.

View File

@ -17,10 +17,10 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ with .Data }}
{{ .ContentLength }} → 42764
{{ .ContentType }} → image/jpeg
@ -28,9 +28,9 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
{{ .StatusCode }} → 200
{{ .TransferEncoding }} → []
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@ -49,5 +49,4 @@ StatusCode
TransferEncoding
: (`string`) The transfer encoding.
[`resources.GetRemote`]: /functions/resources/getremote/

View File

@ -9,8 +9,15 @@ action:
- methods/resource/Data
returnType: resource.resourceError
signatures: [RESOURCE.Err]
expiryDate: 2026-01-31
---
{{% deprecated-in 0.141.0 %}}
Use the `try` statement instead. See [example].
[example]: /functions/go-template/try/#example
{{% /deprecated-in %}}
The `Err` method on a resource returned by the [`resources.GetRemote`] function returns an error message if the HTTP request fails, else nil. If you do not handle the error yourself, Hugo will fail the build.
[`resources.GetRemote`]: /functions/resources/getremote/

View File

@ -9,7 +9,7 @@ byline: "[bep](https://github.com/bep), Hugo Lead"
The **Lets Encrypt website** has a common set of elements: A landing page and some other static info-pages, a document section, a blog, and a documentation section. Having it moved to Hugo was mostly motivated by a _simpler administration and Hugo's [multilingual support](/content-management/multilingual/)_. They already serve HTTPS to more than 60 million domains, and having the documentation available in more languages will increase that reach.[^1]
{{< tweet user="letsencrypt" id="971755920639307777" >}}
{{< x user="letsencrypt" id="971755920639307777" >}}
I helped them port the site from Jekyll to Hugo. There are usually very few surprises doing this. I know Hugo very well, but working on sites with a history usually comes up with something new.

View File

@ -27,8 +27,7 @@ layouts/
├── head/
│ ├── favicons.html
│ ├── metadata.html
│ ├── prerender.html
│ └── twitter.html
│ └── prerender.html
└── header/
├── site-header.html
└── site-nav.html

View File

@ -54,6 +54,9 @@ chroma:
- Aliases:
- armasm
Name: ArmAsm
- Aliases:
- atl
Name: ATL
- Aliases:
- autohotkey
- ahk
@ -88,6 +91,9 @@ chroma:
- dosbatch
- winbatch
Name: Batchfile
- Aliases:
- beef
Name: Beef
- Aliases:
- bib
- bibtex
@ -190,6 +196,9 @@ chroma:
- Aliases:
- css
Name: CSS
- Aliases:
- csv
Name: CSV
- Aliases:
- cue
Name: CUE
@ -308,7 +317,7 @@ chroma:
- Gherkin
Name: Gherkin
- Aliases:
- gleam>
- gleam
Name: Gleam
- Aliases:
- glsl
@ -414,6 +423,12 @@ chroma:
- Aliases:
- json
Name: JSON
- Aliases:
- jsonata
Name: JSONata
- Aliases:
- jsonnet
Name: Jsonnet
- Aliases:
- julia
- jl
@ -464,7 +479,8 @@ chroma:
Name: Matlab
- Aliases:
- mcfunction
Name: mcfunction
- mcf
Name: MCFunction
- Aliases:
- meson
- meson.build
@ -521,6 +537,11 @@ chroma:
- nixos
- nix
Name: Nix
- Aliases:
- nsis
- nsi
- nsh
Name: NSIS
- Aliases:
- objective-c
- objectivec
@ -752,6 +773,9 @@ chroma:
- Aliases:
- smarty
Name: Smarty
- Aliases:
- snbt
Name: SNBT
- Aliases:
- snobol
Name: Snobol
@ -862,6 +886,9 @@ chroma:
- Aliases:
- typoscripthtmldata
Name: TypoScriptHtmlData
- Aliases:
- typst
Name: Typst
- Aliases: null
Name: ucode
- Aliases:
@ -904,6 +931,9 @@ chroma:
- Aliases:
- wgsl
Name: WebGPU Shading Language
- Aliases:
- vtt
Name: WebVTT
- Aliases:
- whiley
Name: Whiley
@ -993,6 +1023,7 @@ config:
dataDir: data
defaultContentLanguage: en
defaultContentLanguageInSubdir: false
defaultOutputFormat: html
deployment:
confirm: false
dryRun: false
@ -1146,7 +1177,6 @@ config:
lineNos: false
lineNumbersInTable: true
noClasses: true
noHl: false
style: monokai
tabWidth: 4
wrapperClass: highlight
@ -3196,6 +3226,11 @@ tpl:
Args: null
Description: ""
Examples: null
Mask:
Aliases: null
Args: null
Description: ""
Examples: null
Opacity:
Aliases: null
Args: null
@ -3221,6 +3256,11 @@ tpl:
Args: null
Description: ""
Examples: null
QR:
Aliases: null
Args: null
Description: ""
Examples: null
Saturation:
Aliases: null
Args: null

View File

@ -36,4 +36,5 @@
'relref' = 'shortcodes/relref.html'
'twitter' = 'shortcodes/twitter.html'
'vimeo' = 'shortcodes/vimeo.html'
'x' = 'shortcodes/x.html'
'youtube' = 'shortcodes/youtube.html'

View File

@ -1,820 +0,0 @@
{
"htmlElements": {
"tags": [
"",
"a",
"article",
"aside",
"blockquote",
"body",
"br",
"button",
"circle",
"code",
"date",
"dd",
"div",
"dl",
"dt",
"em",
"figcaption",
"figure",
"footer",
"form",
"g",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"head",
"header",
"hr",
"html",
"i",
"iframe",
"img",
"li",
"link",
"main",
"meta",
"nav",
"noscript",
"ol",
"p",
"path",
"pre",
"script",
"section",
"small",
"span",
"strong",
"style",
"sup",
"svg",
"table",
"tbody",
"td",
"thead",
"time",
"title",
"tr",
"ul"
],
"classes": [
"!('about'",
"!('content-management'",
"!('contribute'",
"!('functions'",
"!('getting-started'",
"!('hosting-and-deployment'",
"!('modules'",
"!('pipes'",
"!('templates'",
"!('tools'",
"!('troubleshooting'",
"!('variables'",
"\u0026\u0026",
"(false",
"(true",
"-ml-px",
"-mr-12",
"-mr-3",
"-translate-x-3",
"-translate-y-2",
"absolute",
"absolute-l",
"active",
"admonition",
"admonition-content",
"admonition-icon",
"anchor",
"b--moon-gray",
"benchstat",
"better",
"bg-accent-color-dark",
"bg-animate",
"bg-black",
"bg-carrot-500",
"bg-cover",
"bg-gradient-to-b",
"bg-gray-100",
"bg-gray-200",
"bg-gray-300",
"bg-gray-50",
"bg-gray-600",
"bg-gray-900",
"bg-green-100",
"bg-mango-300",
"bg-mango-50",
"bg-near-white",
"bg-opacity-20",
"bg-opacity-75",
"bg-orange-500",
"bg-steel-200",
"bg-steel-500",
"bg-steel-600",
"bg-steel-800",
"bg-steel-900",
"bg-white",
"blTK",
"black",
"block",
"bmt1",
"border",
"border-0",
"border-2",
"border-b",
"border-gray-100",
"border-gray-200",
"border-gray-300",
"border-l",
"border-none",
"border-r",
"border-solid",
"border-t",
"border-transparent",
"bottom-0",
"break-inside-avoid-l",
"btn-primary",
"c",
"c1",
"chroma",
"clearfix",
"cm",
"code-copy-content",
"code-toggle",
"column-count-3-l",
"column-gap-1-l",
"configs",
"copy",
"cp",
"cursor-pointer",
"dark:bg-red-800",
"dark:border-gray-800",
"delta",
"details",
"dim",
"disabled",
"divide-gray-200",
"divide-x",
"err",
"f2-fluid",
"f6",
"filename",
"fill-current",
"fixed",
"fixed-lTK",
"flex",
"flex-1",
"flex-auto",
"flex-auto-ns",
"flex-col",
"flex-column",
"flex-none",
"flex-shrink-0",
"flex-wrap",
"fn",
"focus:border-steel-500",
"focus:outline-none",
"focus:ring-1",
"focus:ring-2",
"focus:ring-inset",
"focus:ring-offset-2",
"focus:ring-steel-500",
"focus:ring-white",
"focus:z-10",
"font-black",
"font-bold",
"font-extrabold",
"font-extralight",
"font-medium",
"font-mono",
"font-normal",
"font-sans",
"font-semibold",
"footnote-backref",
"footnote-ref",
"footnotes",
"from-primarydark",
"gap-4",
"ge",
"grid",
"grid-cols-1",
"group",
"grow",
"gs",
"gu",
"h-0",
"h-0.5",
"h-10",
"h-12",
"h-16",
"h-2",
"h-32",
"h-5",
"h-6",
"h-64",
"h-8",
"h-full",
"h-screen",
"h6",
"hidden",
"highlight",
"hl",
"hover",
"hover-bg-green",
"hover-bg-near-white",
"hover-bg-primary-color",
"hover-bg-primary-color-dark",
"hover-blue",
"hover:bg-gray-300",
"hover:bg-gray-50",
"hover:bg-steel-500",
"hover:bg-steel-700",
"hover:border",
"hover:text-gray-200",
"hover:text-gray-900",
"hover:text-hotpink-400",
"hover:text-hotpink-600",
"hover:text-limegreen-900",
"hover:text-royalblue-700",
"hover:text-steel-500",
"hover:text-white",
"img",
"in",
"inline-block",
"inline-flex",
"inset-0",
"inset-x-0",
"instagram-media",
"items-center",
"items-start",
"justify-between",
"justify-center",
"justify-end",
"k",
"kc",
"kd",
"kr",
"kt",
"l",
"language-asciidoc",
"language-bash",
"language-go",
"language-go-html-template",
"language-go-text-template",
"language-html",
"language-js",
"language-json",
"language-markdown",
"language-md",
"language-ps1",
"language-sh",
"language-svg",
"language-text",
"language-toml",
"language-txt",
"language-xml",
"language-yaml",
"language-yml",
"lazyload",
"ld",
"lead",
"leading-none",
"leading-normal",
"leading-relaxed",
"leading-snug",
"leading-tight",
"left-0",
"lg:bg-steel-700",
"lg:block",
"lg:flex",
"lg:flex-grow",
"lg:flex-shrink-0",
"lg:hidden",
"lg:inline-block",
"lg:items-center",
"lg:max-w-lg",
"lg:mb-0",
"lg:mr-auto",
"lg:mt-0",
"lg:p-4",
"lg:pb-5",
"lg:prose-lg",
"lg:pt-0",
"lg:px-4",
"lg:px-5",
"lg:px-8",
"lg:py-5",
"lg:py-8",
"lg:rounded-md",
"lg:shadow-lg",
"lg:space-x-4",
"lg:text-5xl",
"lg:w-1/2",
"lg:w-1/4",
"lg:w-1/5",
"lg:w-11/12",
"lg:w-3/5",
"lg:w-4/5",
"lg:w-auto",
"light-gray",
"link",
"list-reset",
"lnt",
"lntable",
"lntd",
"m",
"m-0",
"m-1",
"max-w-6xl",
"max-w-lg",
"max-w-xs",
"mb-0",
"mb-1",
"mb-2",
"mb-3",
"mb-4",
"mb-8",
"mb5",
"mb7",
"md:flex",
"md:flex-col",
"md:flex-grow",
"md:grid-cols-2",
"md:mt-8",
"md:pb-12",
"menu))",
"menu['about']",
"menu['content-management']",
"menu['contribute']",
"menu['functions']",
"menu['getting-started']",
"menu['hosting-and-deployment']",
"menu['modules']",
"menu['pipes']",
"menu['templates']",
"menu['tools']",
"menu['troubleshooting']",
"menu['variables']",
"mf",
"mi",
"min-h-screen",
"min-w-0",
"minor",
"ml-1",
"ml-10",
"ml-4",
"ml-6",
"ml1",
"mr-1.5",
"mr-10",
"mr-3",
"mr-4",
"mt-0",
"mt-1",
"mt-2",
"mt-4",
"mt-5",
"mt-6",
"mt-8",
"mt3",
"mt4",
"mv2",
"mv3",
"mv4",
"mv6",
"mw-100",
"mw5-l",
"mx-auto",
"my-0",
"n",
"na",
"navbar-menu",
"nb",
"needs-js",
"nested-blockquote",
"nested-copy-seperator",
"nested-img",
"nested-links",
"nested-linksTK",
"nested-list-reset",
"nf",
"ni",
"nightwind",
"nightwind-prevent",
"nightwind-prevent-block",
"nn",
"no-js",
"no-underline",
"nodelta",
"note",
"note-icon",
"nt",
"nt3",
"nv",
"nx",
"o",
"o-0",
"o-80",
"oldnew",
"opacity-60",
"open",
"order-0",
"order-0-l",
"order-1",
"order-1-l",
"order-2",
"output-content",
"overflow-hidden",
"overflow-x-scroll",
"overflow-y-auto",
"p",
"p-0",
"p-2",
"p-3",
"p-4",
"p-5",
"p-8",
"pa4-m",
"page-item",
"page-link",
"pagination",
"pb-1",
"pb-2",
"pb-3",
"pb-4",
"pb-5",
"pb-7",
"pb-8",
"pb2",
"ph1",
"ph2",
"ph4",
"pl-0",
"pl-1",
"pl-2",
"pl-3",
"pl-6",
"pl5-l",
"pr-2",
"pr1",
"primary-color",
"prose",
"pt-0",
"pt-1",
"pt-2",
"pt-3",
"pt-4",
"pt-5",
"pv1",
"px-0",
"px-2",
"px-3",
"px-4",
"py-0",
"py-0.5",
"py-1.5",
"py-2",
"py-3",
"py-4",
"py-6",
"relative",
"right-0",
"rounded",
"rounded-full",
"rounded-l-lg",
"rounded-l-md",
"rounded-lg",
"rounded-md",
"rounded-r-md",
"row",
"s",
"s1",
"s2",
"san-serif",
"se",
"shadow",
"shadow-lg",
"shadow-md",
"shadow-sm",
"show",
"sm:flex",
"sm:grid-cols-2",
"sm:mb-0",
"sm:mt-0",
"sm:mt-8",
"sm:p-4",
"sm:pb-0",
"sm:pb-6",
"sm:pt-3",
"sm:pt-5",
"sm:px-4",
"sm:px-5",
"sm:px-6",
"sm:py-0",
"sm:py-4",
"sm:py-5",
"sm:py-6",
"sm:text-2xl",
"sm:text-4xl",
"sm:text-base",
"sm:text-center",
"sm:text-left",
"sm:w-1/2",
"sm:w-1/5",
"sm:w-11/12",
"sm:w-4/5",
"space-x-4",
"space-x-8",
"space-y-1",
"sr-only",
"table",
"table-bordered",
"tc",
"text-2xl",
"text-3xl",
"text-4xl",
"text-5xl",
"text-base",
"text-black",
"text-center",
"text-gray-200",
"text-gray-300",
"text-gray-400",
"text-gray-500",
"text-gray-600",
"text-gray-900",
"text-lg",
"text-limegreen-600",
"text-limegreen-700",
"text-mango-100",
"text-mango-300",
"text-md",
"text-royalblue-500",
"text-royalblue-600",
"text-sm",
"text-steel-100",
"text-steel-500",
"text-steel-900",
"text-white",
"text-xl",
"text-xs",
"tile",
"tip",
"tip-icon",
"to-steel-800",
"top-0",
"top-2",
"tracked",
"tracking-normal",
"tracking-tight",
"transform",
"twitter-tweet",
"unchanged",
"uppercase",
"v-base",
"v-mid",
"v-top",
"w",
"w-1/5",
"w-10",
"w-11/12",
"w-12",
"w-14",
"w-2",
"w-2/3",
"w-30-l",
"w-32",
"w-5",
"w-50-m",
"w-6",
"w-64",
"w-8",
"w-80-nsTK",
"w-96",
"w-auto",
"w-full",
"w-two-third-l",
"warning",
"whitespace-no-wrap",
"worse",
"x",
"xl:flex",
"xl:flex-col",
"z-0",
"z-40",
"z-999",
"||"
],
"ids": [
".gitlab-ci.yml",
"/blog/greatest-city/index.html",
"/content/actors/bruce-willis/_index.md",
"/layouts/shortcodes/img.html",
"/layouts/shortcodes/vimeo.html",
"/layouts/shortcodes/year.html",
"/layouts/shortcodes/youtube.html",
"/themes/yourtheme/layouts/review/single.html",
"404.html",
"TableOfContents",
"addrobotstxt.sh",
"all-taxonomies-keys-and-pages.html",
"all-taxonomies.html",
"archetype-example.sh",
"archetypes/functions.md",
"archetypes/newsletter.md",
"articles.html",
"asciicast-3mf1JGaN0AX0Z7j5kLGl3hSh8",
"asciicast-7naKerRYUGVPj8kiDmdh5k5h9",
"asciicast-BvJBsF6egk9c163bMsObhuNXj",
"asciicast-ItACREbFgvJ0HjnSNeTknxWy9",
"asciicast-Lc5iwTVny2kuUC8lqvNnL6oDU",
"asciicast-eUojYCfRTZvkEiqc52fUsJRBR",
"bad-url-sidebar-menu-output.html",
"base-64-output.html",
"base64-input.html",
"baseof.html",
"bf-config.toml",
"bf-config.yml",
"boxfile.yml",
"breadcrumb.html",
"check-title-length.html",
"clone-herring-cove-theme.sh",
"config.toml",
"content-header.html",
"content-image.md",
"content/blog/greatest-city.md",
"content/posts/_index.md",
"content/posts/default-function-example.md",
"content/posts/my-awesome-post.md",
"content/posts/my-post.md",
"content/posts/old-post.md",
"content/posts/old-url.md",
"content/tutorials/learn-html.md",
"correct-url-sidebar-menu-output.html",
"delimit-example-front-matter.toml",
"delimit-page-tags-final-and-input.html",
"delimit-page-tags-final-and-output.html",
"delimit-page-tags-input.html",
"delimit-page-tags-output.html",
"disqus.html",
"dot-notation-default-return-value.html",
"dot-notation-default-value.html",
"example-tweet-input.md",
"example-tweet-output.html",
"example-vimeo-input.md",
"example-vimeo-output.html",
"example-youtube-input-with-autoplay.md",
"example-youtube-input-with-title.md",
"example-youtube-input.md",
"example-youtube-output.html",
"example.com/posts/index.html",
"example.com/quote/index.html",
"external-links.svg",
"figure-input-example.md",
"figure-output-example.html",
"first-and-where-together.html",
"fn:1",
"fn:2",
"fnref:1",
"fnref:2",
"footer.html",
"from-gh.sh",
"gist-input.md",
"gist-output.html",
"gitignore.sh",
"gohugoio",
"grab-top-two-tags.html",
"header.html",
"highlight-example.md",
"how-many-posts.html",
"hugo-new-site.sh",
"if-instead-of-default.html",
"img-output.html",
"index.html",
"instagram-hide-caption-output.html",
"instagram-input-hide-caption.md",
"instagram-input.md",
"install-brew.sh",
"install-extended-with-chocolatey.ps1",
"install-go.sh",
"install-openssh.sh",
"install-with-chocolatey.ps1",
"install-with-homebrew.sh",
"install-with-linuxbrew.sh",
"install-with-macports.sh",
"install.sh",
"layout/_default/section.html",
"layout/_default/single.html",
"layouts/404.html",
"layouts/_default/_markup/render-heading.html",
"layouts/_default/_markup/render-image.html",
"layouts/_default/_markup/render-link.html",
"layouts/_default/baseof.html",
"layouts/_default/li.html",
"layouts/_default/list.html",
"layouts/_default/section.html",
"layouts/_default/single.html",
"layouts/_default/summary.html",
"layouts/_default/taxonomy.html",
"layouts/index.html",
"layouts/partials/all-taxonomies.html",
"layouts/partials/alllanguages.html",
"layouts/partials/bad-url-sidebar-menu.html",
"layouts/partials/breadcrumb.html",
"layouts/partials/by-date-reverse.html",
"layouts/partials/by-date.html",
"layouts/partials/by-expiry-date.html",
"layouts/partials/by-group-by-page.html",
"layouts/partials/by-last-mod.html",
"layouts/partials/by-length.html",
"layouts/partials/by-link-title.html",
"layouts/partials/by-nested-param.html",
"layouts/partials/by-page-date.html",
"layouts/partials/by-page-expiry-date.html",
"layouts/partials/by-page-field.html",
"layouts/partials/by-page-lastmod.html",
"layouts/partials/by-page-param-as-date.html",
"layouts/partials/by-page-param.html",
"layouts/partials/by-page-publish-date.html",
"layouts/partials/by-publish-date.html",
"layouts/partials/by-rating.html",
"layouts/partials/by-title.html",
"layouts/partials/by-weight.html",
"layouts/partials/content-header.html",
"layouts/partials/correct-url-sidebar-menu.html",
"layouts/partials/default-order.html",
"layouts/partials/disqus.html",
"layouts/partials/footer.html",
"layouts/partials/get-csv.html",
"layouts/partials/groups.html",
"layouts/partials/head.html",
"layouts/partials/header.html",
"layouts/partials/i18nlist.html",
"layouts/partials/post-tag-link.html",
"layouts/partials/post-tag-list.html",
"layouts/partials/related.html",
"layouts/partials/schemaorg-metadata.html",
"layouts/partials/sidebar.html",
"layouts/partials/svgs/external-links.svg",
"layouts/partials/toc.html",
"layouts/partials/twitter.html",
"layouts/partials/upcoming-events.html",
"layouts/posts/single.html",
"layouts/robots.txt",
"layouts/section/articles.html",
"layouts/section/posts.html",
"layouts/shortcodes/gallery.html",
"layouts/shortcodes/img.html",
"layouts/shortcodes/imgproc.html",
"li.html",
"links-to-all-tags.html",
"list.html",
"netlify.toml",
"note-with-heading.html",
"note-with-heading.md",
"page-list-with-summaries.html",
"partial-cached-example.html",
"partials/templates/random-tweets.html",
"post-tag-list.html",
"prose",
"push-wecker-to-gh.sh",
"range-through-tags-w-global.html",
"remove-herring-cove-git.sh",
"robots.txt",
"schemaorg-metadata.html",
"section.html",
"setup-gh-repo.sh",
"shuffle-input.html",
"shuffle-output.html",
"sidebar.html",
"single.html",
"slice.html",
"summary.html",
"syntax-highlighted.html",
"tags-range-with-page-variable.html",
"taxonomy.html",
"time-passed.html",
"tip-output.html",
"toc.html",
"tutorials/learn-html/index.html",
"tweets.html",
"unix-to-month-integer.html",
"upcoming-events.html",
"using-tip.md",
"variable-as-default-value.html",
"vimeo-iframes.html",
"warning-admonition-input.md",
"warning-admonition-output.html",
"wercker-build-step.yml",
"wercker.yml",
"where-intersect-variables.html",
"with-instead-of-default.html",
"yourbaseurl/review/book01/index.html",
"youtube-embed.html"
]
}
}

View File

@ -0,0 +1,43 @@
{{ $author := .context.Params.author }}
{{ if $author }}
<aside class="mw5 center bg-white br3 pa3 pa4-ns mv3 ba b--black-10 nested-links">
{{ $data := "" }}
{{ $url := urls.JoinPath "https://api.github.com/users" $author }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
<div class="tc">
{{ with $data }}
{{ with .avatar_url }}
<a href="{{ . }}" class="link hover-bg-light-gray pa1 br-100">
<img src="{{ . }}&size={{ $.size }}" alt="" class="br-100 ba b--light-gray">
</a>
{{ end }}
{{ with .name }}
<h3 class="f4">
<a href="{{ $data.html_url }}" class="link dim">
{{ . | htmlEscape }}
</a>
</h3>
<hr class="mw3 bb bw1 b--black-10">
{{ end }}
{{ with .bio }}
<p class="lh-copy measure center f6 black-70">
{{ . | htmlEscape }}
</p>
{{ end }}
{{ end }}
</div>
</aside>
{{ end }}

View File

@ -0,0 +1,36 @@
{{ $author := .context.Params.author }}
{{ if $author }}
<aside class="mw5 br3 mv3 nested-links">
{{ $data := "" }}
{{ $url := urls.JoinPath "https://api.github.com/users" $author }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $data = . | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ with $data }}
{{ with .name }}
<h3 class="f4 dib">
{{ . | htmlEscape }}
</h3>
{{ end }}
{{ with .bio }}
<p class="lh-copy measure center mt0 f6 black-60">
{{ . | htmlEscape }}
</p>
{{ end }}
{{ with .html_url }}
<a href="{{ . }}" class="link dim v-mid dib">
{{ partial "svg/github-squared.svg" (dict "fill" "gray" "width" "16" "height" "18") }}
</a>
{{ end }}
{{ end }}
</aside>
{{ end }}

View File

@ -0,0 +1,23 @@
{{/*
Parses the serialized data from the given URL and returns a map or an array.
Supports CSV, JSON, TOML, YAML, and XML.
@param {string} . The URL from which to retrieve the serialized data.
@returns {any}
@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }}
*/}}
{{ $url := . }}
{{ $data := dict }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else with .Value }}
{{ $data = .Content | transform.Unmarshal }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ return $data }}

391
layouts/shortcodes/img.html Normal file
View File

@ -0,0 +1,391 @@
{{- /*
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" "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 := "di va b--black-20" }}
{{- if eq $filter "mask" }}
{{- $class = "di va" }}
{{- end }}
{{- if $example }}
<p>Original</p>
<img class="{{ $class}}" style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
<p>Processed</p>
<img class="{{ $class }}" 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 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 -}}