From: Bjørn Erik Pedersen Date: Thu, 24 Apr 2025 08:23:16 +0000 (+0200) Subject: Squashed 'docs/' changes from dc7a9ae12..b654fcba0 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b3d87dd0fd746f07f9afa6e6a2969aea41da6a38;p=brevno-suite%2Fhugo Squashed 'docs/' changes from dc7a9ae12..b654fcba0 b654fcba0 content: Fix links d44357418 content: Update GitLab Pages workflow example 33968c7e2 content: Update Netlify configuration file a6d0c8c50 content: Update GitHub Pages workflow example d1aabfa36 content: Fix broken link 7b50139a6 content: Miscellaneous edits a30e2c189 Menus: add forgotten link target 5c2aa88b4 content: Updates for v0.146.7 114413c18 netlify: Hugo 0.146.7 67e9261b1 netlify: Hugo 0.146.6 efa040229 content: Update templates/embedded.md b8f888c76 theme: Rename internal templates from partials/ to _partials/ 727178cbb content: Fix broken anchor links 0f12708f1 Fix typo 380b1c163 Update Current.md 8b500f3e5 netlify: Hugo 0.146.5 e3d6b6fad netlify: Hugo 0.146.4 ac1b92713 content: Fix text formatting in templates/partial.md 719329530 content: Clarify usage of template function a95eca524 theme: Misc adjustments for the themes site 8e6c26067 Add package.hugo.json 9691007fb netlify: Hugo 0.146.3 ec08acc59 netlify: Hugo 0.146.2 8f320a0b6 netlify: Hugo 0.146.1 d5e6cb618 content: Remove expired new-in badges b5779d7fc content: Update templates.Current function 5df1229d5 theme: Move templates to new structure a7a6a614d theme: Remove accidentally added template 195b368e8 content: Miscellaneous updates related to v0.146.0 0a906ad49 netlify: Hugo 0.146.0 git-subtree-dir: docs git-subtree-split: b654fcba0d4385da1e47179ef3763f277f044242 --- diff --git a/content/en/configuration/introduction.md b/content/en/configuration/introduction.md index 121a483c4..8f8ad4c1e 100644 --- a/content/en/configuration/introduction.md +++ b/content/en/configuration/introduction.md @@ -249,7 +249,7 @@ HUGO_FILE_LOG_FORMAT HUGO_MEMORYLIMIT : {{< new-in 0.123.0 />}} -: (`int`) The maximum amount of system memory, in gigabytes, that Hugo can use while rendering your site. Default is 25% of total system memory. Note that The `HUGO_MEMORYLIMIT` is a “best effort” setting. Don't expect Hugo to build a million pages with only 1 GB memory. You can get more information about how this behaves during the build by building with `hugo --logLevel info` and look for the `dynacache` label. +: (`int`) The maximum amount of system memory, in gigabytes, that Hugo can use while rendering your site. Default is 25% of total system memory. Note that `HUGO_MEMORYLIMIT` is a "best effort" setting. Don't expect Hugo to build a million pages with only 1 GB of memory. You can get more information about how this behaves during the build by building with `hugo --logLevel info` and look for the `dynacache` label. HUGO_NUMWORKERMULTIPLIER : (`int`) The number of workers used in parallel processing. Default is the number of logical CPUs. diff --git a/content/en/content-management/menus.md b/content/en/content-management/menus.md index ab1bcbfa1..6d01173dc 100644 --- a/content/en/content-management/menus.md +++ b/content/en/content-management/menus.md @@ -11,7 +11,7 @@ aliases: [/extras/menus/] To create a menu for your site: 1. Define the menu entries -1. [Localize] each entry +1. [Localize](multilingual/#menus) each entry 1. Render the menu with a [template] Create multiple menus, either flat or nested. For example, create a main menu for the header, and a separate menu for the footer. diff --git a/content/en/contribute/documentation.md b/content/en/contribute/documentation.md index 1d185d21d..68129912a 100644 --- a/content/en/contribute/documentation.md +++ b/content/en/contribute/documentation.md @@ -112,7 +112,7 @@ Yes → Hugo is fast. ### Function and method descriptions -Start descriptions in the functions and methods sections with "Returns", of for booelan values, "Reports whether". +Start descriptions in the functions and methods sections with "Returns", or for boolean values, "Reports whether". ### File paths and names diff --git a/content/en/functions/collections/Where.md b/content/en/functions/collections/Where.md index 1df84afc4..84fd1d21e 100644 --- a/content/en/functions/collections/Where.md +++ b/content/en/functions/collections/Where.md @@ -87,7 +87,6 @@ Use any of the following logical operators: : (`bool`) Reports whether the given field value (a slice) contains one or more elements in common with `VALUE`. See [details](/functions/collections/intersect). `like` -: {{< new-in 0.116.0 />}} : (`bool`) Reports whether the given field value matches the [regular expression](g) specified in `VALUE`. Use the `like` operator to compare `string` values. The `like` operator returns `false` when comparing other data types to the regular expression. > [!note] @@ -167,8 +166,6 @@ For example, to return a collection of pages where any of the terms in the "genr ## Regular expression comparison -{{< new-in 0.116.0 />}} - To return a collection of pages where the "author" page parameter begins with either "victor" or "Victor": ```go-html-template diff --git a/content/en/functions/css/Sass.md b/content/en/functions/css/Sass.md index 1d5487130..03a4c7451 100644 --- a/content/en/functions/css/Sass.md +++ b/content/en/functions/css/Sass.md @@ -12,26 +12,6 @@ params: {{< new-in 0.128.0 />}} -```go-html-template -{{ with resources.Get "sass/main.scss" }} - {{ $opts := dict - "enableSourceMap" (not hugo.IsProduction) - "outputStyle" (cond hugo.IsProduction "compressed" "expanded") - "targetPath" "css/main.css" - "transpiler" "libsass" - }} - {{ with . | toCSS $opts }} - {{ if hugo.IsProduction }} - {{ with . | fingerprint }} - - {{ end }} - {{ else }} - - {{ end }} - {{ end }} -{{ end }} -``` - Transpile Sass to CSS using the LibSass transpiler included in Hugo's extended and extended/deploy editions, or [install Dart Sass](#dart-sass) to use the latest features of the Sass language. Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both. @@ -41,54 +21,70 @@ Sass has two forms of syntax: [SCSS] and [indented]. Hugo supports both. ## Options -transpiler -: (`string`) The transpiler to use, either `libsass` (default) or `dartsass`. Hugo's extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass) below. - -targetPath -: (`string`) If not set, the transformed resource's target path will be the original path of the asset file with its extension replaced by `.css`. - -vars -: (`map`) A map of key-value pairs that will be available in the `hugo:vars` namespace. Useful for [initializing Sass variables from Hugo templates](https://discourse.gohugo.io/t/42053/). - -```scss -// LibSass -@import "hugo:vars"; +enableSourceMap +: (`bool`) Whether to generate a source map. Default is `false`. -// Dart Sass -@use "hugo:vars" as v; -``` +includePaths +: (`slice`) A slice of paths, relative to the project root, that the transpiler will use when resolving `@use` and `@import` statements. outputStyle -: (`string`) Output styles available to LibSass include `nested` (default), `expanded`, `compact`, and `compressed`. Output styles available to Dart Sass include `expanded` (default) and `compressed`. +: (`string`) The output style of the resulting CSS. With LibSass, one of `nested` (default), `expanded`, `compact`, or `compressed`. With Dart Sass, either `expanded` (default) or `compressed`. precision -: (`int`) Precision of floating point math. Not applicable to Dart Sass. +: (`int`) The precision of floating point math. Applicable to LibSass. Default is `8`. -enableSourceMap -: (`bool`) Whether to generate a source map. Default is `false`. +silenceDeprecations +: {{< new-in 0.139.0 />}} +: (`slice`) A slice of deprecation IDs to silence. IDs are enclosed in brackets within Dart Sass warning messages (e.g., `import` in `WARN Dart Sass: DEPRECATED [import]`). Applicable to Dart Sass. Default is `false`. + +silenceDependencyDeprecations +: {{< new-in 0.146.0 />}} +: (`bool`) Whether to silence deprecation warnings from dependencies, where a dependency is considered any file transitively imported through a load path. This does not apply to `@warn` or `@debug` rules.Default is `false`. sourceMapIncludeSources -: (`bool`) Whether to embed sources in the generated source map. Not applicable to LibSass. Default is `false`. +: (`bool`) Whether to embed sources in the generated source map. Applicable to Dart Sass. Default is `false`. -includePaths -: (`slice`) A slice of paths, relative to the project root, that the transpiler will use when resolving `@use` and `@import` statements. +targetPath +: (`string`) The publish path for the transformed resource, relative to the[`publishDir`]. If unset, the target path defaults to the asset's original path with a `.css` extension. + +transpiler +: (`string`) The transpiler to use, either `libsass` or `dartsass`. Hugo's extended and extended/deploy editions include the LibSass transpiler. To use the Dart Sass transpiler, see the [installation instructions](#dart-sass). Default is `libsass`. + +vars +: (`map`) A map of key-value pairs that will be available in the `hugo:vars` namespace. Useful for [initializing Sass variables from Hugo templates](https://discourse.gohugo.io/t/42053/). + + ```scss + // LibSass + @import "hugo:vars"; + + // Dart Sass + @use "hugo:vars" as v; + ``` -```go-html-template -{{ $opts := dict - "transpiler" "dartsass" - "targetPath" "css/style.css" - "vars" site.Params.styles - "enableSourceMap" (not hugo.IsProduction) - "includePaths" (slice "node_modules/bootstrap/scss") -}} -{{ with resources.Get "sass/main.scss" | toCSS $opts | minify | fingerprint }} - +## Example + +```go-html-template {copy=true} +{{ with resources.Get "sass/main.scss" }} + {{ $opts := dict + "enableSourceMap" (not hugo.IsProduction) + "outputStyle" (cond hugo.IsProduction "compressed" "expanded") + "targetPath" "css/main.css" + "transpiler" "dartsass" + "vars" site.Params.styles + "includePaths" (slice "node_modules/bootstrap/scss") + }} + {{ with . | toCSS $opts }} + {{ if hugo.IsProduction }} + {{ with . | fingerprint }} + + {{ end }} + {{ else }} + + {{ end }} + {{ end }} {{ end }} ``` -silenceDeprecations -: (`slice`) {{< new-in 0.139.0 />}} A slice of deprecation IDs to silence. The deprecation IDs are printed to in the warning message, e.g "import" in `WARN Dart Sass: DEPRECATED [import] ...`. This is for Dart Sass only. - ## Dart Sass Hugo's extended and extended/deploy editions include [LibSass] to transpile Sass to CSS. In 2020, the Sass team deprecated LibSass in favor of [Dart Sass]. @@ -121,6 +117,9 @@ You may also install [prebuilt binaries] for Linux, macOS, and Windows. Run `hugo env` to list the active transpilers. +> [!note] +> If you build Hugo from source and run `mage test -v`, the test will fail if you install Dart Sass as a Snap package. This is due to the Snap package's strict confinement model. + ### Installing in a production environment For [CI/CD](g) deployments (e.g., GitHub Pages, GitLab Pages, Netlify, etc.) you must edit the workflow to install Dart Sass before Hugo builds the site[^2]. Some providers allow you to use one of the package managers above, or you can download and extract one of the prebuilt binaries. @@ -136,8 +135,6 @@ To install Dart Sass for your builds on GitHub Pages, add this step to the GitHu run: sudo snap install dart-sass ``` -If you are using GitHub Pages for the first time with your repository, GitHub provides a [starter workflow] for Hugo that includes Dart Sass. This is the simplest way to get started. - #### GitLab Pages To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file should look something like this: @@ -194,34 +191,6 @@ command = """\ """ ``` -### Example - -To transpile with Dart Sass, set `transpiler` to `dartsass` in the options map passed to `css.Sass`. For example: - -```go-html-template -{{ with resources.Get "sass/main.scss" }} - {{ $opts := dict - "enableSourceMap" (not hugo.IsProduction) - "outputStyle" (cond hugo.IsProduction "compressed" "expanded") - "targetPath" "css/main.css" - "transpiler" "dartsass" - }} - {{ with . | toCSS $opts }} - {{ if hugo.IsProduction }} - {{ with . | fingerprint }} - - {{ end }} - {{ else }} - - {{ end }} - {{ end }} -{{ end }} -``` - -### Miscellaneous - -If you build Hugo from source and run `mage test -v`, the test will fail if you install Dart Sass as a Snap package. This is due to the Snap package's strict confinement model. - [brew.sh]: https://brew.sh/ [chocolatey.org]: https://community.chocolatey.org/packages/sass [dart sass]: https://sass-lang.com/dart-sass @@ -232,3 +201,4 @@ If you build Hugo from source and run `mage test -v`, the test will fail if you [snap package]: /installation/linux/#snap [snapcraft.io]: https://snapcraft.io/dart-sass [starter workflow]: https://github.com/actions/starter-workflows/blob/main/pages/hugo.yml +[`publishDir`]: /configuration/all/#publishdir diff --git a/content/en/functions/go-template/template.md b/content/en/functions/go-template/template.md index dac1fa3be..053cfcc22 100644 --- a/content/en/functions/go-template/template.md +++ b/content/en/functions/go-template/template.md @@ -10,7 +10,18 @@ params: signatures: ['template NAME [CONTEXT]'] --- -Use the `template` function to execute [embedded templates]. For example: +Use the `template` function to execute any of these [embedded templates](g): + +- [`disqus.html`] +- [`google_analytics.html`] +- [`opengraph.html`] +- [`pagination.html`] +- [`schema.html`] +- [`twitter_cards.html`] + + + +For example: ```go-html-template {{ range (.Paginate .Pages).Pages }} @@ -39,8 +50,21 @@ The example above can be rewritten using an [inline partial] template: {{ end }} ``` +The key distinctions between the preceding two examples are: + +1. Inline partials are globally scoped. That means that an inline partial defined in _one_ template may be called from _any_ template. +2. Leveraging the [`partialCached`] function when calling an inline partial allows for performance optimization through result caching. +3. An inline partial can [`return`] a value of any data type instead of rendering a string. + {{% include "/_common/functions/go-template/text-template.md" %}} +[`disqus.html`]: /templates/embedded/#disqus +[`google_analytics.html`]: /templates/embedded/#google-analytics +[`opengraph.html`]: /templates/embedded/#open-graph +[`pagination.html`]: /templates/embedded/#pagination +[`partialCached`]: /functions/partials/includecached/ [`partial`]: /functions/partials/include/ +[`return`]: /functions/go-template/return/ +[`schema.html`]: /templates/embedded/#schema +[`twitter_cards.html`]: /templates/embedded/#x-twitter-cards [inline partial]: /templates/partial/#inline-partials -[embedded templates]: /templates/embedded/ diff --git a/content/en/functions/templates/Current.md b/content/en/functions/templates/Current.md new file mode 100644 index 000000000..805aeec05 --- /dev/null +++ b/content/en/functions/templates/Current.md @@ -0,0 +1,155 @@ +--- +title: templates.Current +description: Returns information about the currently executing template. +categories: [] +keywords: [] +params: + functions_and_methods: + aliases: [] + returnType: tpl.CurrentTemplateInfo + signatures: [templates.Current] +--- + +> [!note] +> This function is experimental and subject to change. + +{{< new-in 0.146.0 />}} + +The `templates.Current` function provides introspection capabilities, allowing you to access details about the currently executing templates. This is useful for debugging complex template hierarchies and understanding the flow of execution during rendering. + +## Methods + +Ancestors +: (`tpl.CurrentTemplateInfos`) Returns a slice containing information about each template in the current execution chain, starting from the parent of the current template and going up towards the initial template called. It excludes any base template applied via `define` and `block`. You can chain the `Reverse` method to this result to get the slice in chronological execution order. + +Base +: (`tpl.CurrentTemplateInfoCommonOps`) Returns an object representing the base template that was applied to the current template, if any. This may be `nil`. + +Filename +: (`string`) Returns the absolute path of the current template. This will be empty for embedded templates. + +Name +: (`string`) Returns the name of the current template. This is usually the path relative to the layouts directory. + +Parent +: (`tpl.CurrentTemplateInfo`) Returns an object representing the parent of the current template, if any. This may be `nil`. + +## Examples + +The examples below help visualize template execution and require a `debug` parameter set to `true` in your site configuration: + +{{< code-toggle file=hugo >}} +[params] +debug = true +{{< /code-toggle >}} + +### Boundaries + +To visually mark where a template begins and ends execution: + +```go-html-template {file="layouts/_default/single.html"} +{{ define "main" }} + {{ if site.Params.debug }} +
[entering {{ templates.Current.Filename }}]
+ {{ end }} + +

{{ .Title }}

+ {{ .Content }} + + {{ if site.Params.debug }} +
[leaving {{ templates.Current.Filename }}]
+ {{ end }} +{{ end }} +``` + +### Call stack + +To display the chain of templates that led to the current one, create a partial template that iterates through its ancestors: + +```go-html-template {file="layouts/partials/template-call-stack.html" copy=true} +{{ with templates.Current }} +
+ {{ range .Ancestors }} + {{ .Filename }}
+ {{ with .Base }} + {{ .Filename }}
+ {{ end }} + {{ end }} +
+{{ end }} +``` + +Then call the partial from any template: + +```go-html-template {file="layouts/partials/footer/copyright.html" copy=true} +{{ if site.Params.debug }} + {{ partial "template-call-stack.html" . }} +{{ end }} +``` + +The rendered template stack would look something like this: + +```text +/home/user/project/layouts/partials/footer/copyright.html +/home/user/project/themes/foo/layouts/partials/footer.html +/home/user/project/layouts/_default/single.html +/home/user/project/themes/foo/layouts/_default/baseof.html +``` + +To reverse the order of the entries, chain the `Reverse` method to the `Ancestors` method: + +```go-html-template {file="layouts/partials/template-call-stack.html" copy=true} +{{ with templates.Current }} +
+ {{ range .Ancestors.Reverse }} + {{ with .Base }} + {{ .Filename }}
+ {{ end }} + {{ .Filename }}
+ {{ end }} +
+{{ end }} +``` + +### VS Code + +To render links that, when clicked, will open the template in Microsoft Visual Studio Code, create a partial template with anchor elements that use the `vscode` URI scheme: + +```go-html-template {file="layouts/partials/template-open-in-vs-code.html" copy=true} +{{ with templates.Current.Parent }} +
+ {{ .Name }} + {{ with .Base }} + {{ .Name }} + {{ end }} +
+{{ end }} +``` + +Then call the partial from any template: + +```go-html-template {file="layouts/_default/single.html" copy=true} +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + + {{ if site.Params.debug }} + {{ partial "template-open-in-vs-code.html" . }} + {{ end }} +{{ end }} +``` + +Use the same approach to render the entire call stack as links: + +```go-html-template {file="layouts/partials/template-call-stack.html" copy=true} +{{ with templates.Current }} +
+ {{ range .Ancestors }} + {{ .Filename }}
+ {{ with .Base }} + {{ .Filename }}
+ {{ end }} + {{ end }} +
+{{ end }} +``` diff --git a/content/en/functions/time/In.md b/content/en/functions/time/In.md new file mode 100644 index 000000000..821eb99b7 --- /dev/null +++ b/content/en/functions/time/In.md @@ -0,0 +1,30 @@ +--- +title: time.In +description: Returns the given date/time as represented in the specified IANA time zone. +categories: [] +keywords: [] +params: + functions_and_methods: + aliases: [] + returnType: time.Time + signatures: [time.In TIMEZONE INPUT] +--- + +{{< new-in 0.146.0 />}} + +The `time.In` function returns the given date/time as represented in the specified [IANA](g) time zone. + +- If the time zone is an empty string or `UTC`, the time is returned in [UTC](g). +- If the time zone is `Local`, the time is returned in the system's local time zone. +- Otherwise, the time zone must be a valid IANA [time zone name]. + +[time zone name]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List + +```go-html-template +{{ $layout := "2006-01-02T15:04:05-07:00" }} +{{ $t := time.AsTime "2025-03-31T14:45:00-00:00" }} + +{{ $t | time.In "America/Denver" | time.Format $layout }} → 2025-03-31T08:45:00-06:00 +{{ $t | time.In "Australia/Adelaide" | time.Format $layout }} → 2025-04-01T01:15:00+10:30 +{{ $t | time.In "Europe/Oslo" | time.Format $layout }} → 2025-03-31T16:45:00+02:00 +``` diff --git a/content/en/functions/transform/Unmarshal.md b/content/en/functions/transform/Unmarshal.md index d159122f5..93168294c 100644 --- a/content/en/functions/transform/Unmarshal.md +++ b/content/en/functions/transform/Unmarshal.md @@ -114,12 +114,14 @@ A remote resource is a file on a remote server, accessible via HTTP or HTTPS. > > `{{ $data = .Content | transform.Unmarshal }}` -## Options +## Working with CSV + +### Options When unmarshaling a CSV file, provide an optional map of options. delimiter -: (`string`) The delimiter used, default is `,`. +: (`string`) The delimiter used. Default is `,`. comment : (`string`) The comment character used in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored. @@ -128,8 +130,85 @@ lazyQuotes : {{< new-in 0.122.0 />}} : (`bool`) Whether to allow a quote in an unquoted field, or to allow a non-doubled quote in a quoted field. Default is `false`. +targetType +: {{< new-in 0.146.7 />}} +: (`string`) The target data type, either `slice` or `map`. Default is `slice`. + +### Examples + +The examples below use this CSV file: + +```csv +"name","type","breed","age" +"Spot","dog","Collie",3 +"Rover","dog","Boxer",5 +"Felix","cat","Calico",7 +``` + +To render an HTML table from a CSV file: + ```go-html-template -{{ $csv := "a;b;c" | transform.Unmarshal (dict "delimiter" ";") }} +{{ $data := slice }} +{{ $file := "pets.csv" }} +{{ with or (.Resources.Get $file) (resources.Get $file) }} + {{ $opts := dict "targetType" "slice" }} + {{ $data = transform.Unmarshal $opts . }} +{{ end }} + +{{ with $data }} + + + + {{ range index . 0 }} + + {{ end }} + + + + {{ range . | after 1 }} + + {{ range . }} + + {{ end }} + + {{ end }} + +
{{ . }}
{{ . }}
+{{ end }} +``` + +To extract a subset of the data, or to sort the data, unmarshal to a map instead of a slice: + +```go-html-template +{{ $data := slice }} +{{ $file := "pets.csv" }} +{{ with or (.Resources.Get $file) (resources.Get $file) }} + {{ $opts := dict "targetType" "map" }} + {{ $data = transform.Unmarshal $opts . }} +{{ end }} + +{{ with sort (where $data "type" "dog") "name" "asc" }} + + + + + + + + + + + {{ range . }} + + + + + + + {{ end }} + +
nametypebreedage
{{ .name }}{{ .type }}{{ .breed }}{{ .age }}
+{{ end }} ``` ## Working with XML diff --git a/content/en/host-and-deploy/host-on-github-pages/index.md b/content/en/host-and-deploy/host-on-github-pages/index.md index 4c00fbc8e..7c3201099 100644 --- a/content/en/host-and-deploy/host-on-github-pages/index.md +++ b/content/en/host-and-deploy/host-on-github-pages/index.md @@ -136,6 +136,8 @@ jobs: key: hugo-${{ github.run_id }} restore-keys: hugo- + - name: Configure Git + run: git config core.quotepath false - name: Build with Hugo run: | hugo \ diff --git a/content/en/host-and-deploy/host-on-gitlab-pages.md b/content/en/host-and-deploy/host-on-gitlab-pages.md index 4b308cc19..4750b0ff3 100644 --- a/content/en/host-and-deploy/host-on-gitlab-pages.md +++ b/content/en/host-and-deploy/host-on-gitlab-pages.md @@ -23,15 +23,15 @@ Define your [CI/CD](g) jobs by creating a `.gitlab-ci.yml` file in the root of y ```yaml {file=".gitlab-ci.yml" copy=true} variables: - DART_SASS_VERSION: 1.85.0 + DART_SASS_VERSION: 1.87.0 GIT_DEPTH: 0 GIT_STRATEGY: clone GIT_SUBMODULE_STRATEGY: recursive - HUGO_VERSION: 0.144.2 - NODE_VERSION: 23.x + HUGO_VERSION: 0.146.7 + NODE_VERSION: 22.x TZ: America/Los_Angeles image: - name: golang:1.23.4-bookworm + name: golang:1.24.2-bookworm pages: script: @@ -53,6 +53,8 @@ pages: - apt-get install -y nodejs # Install Node.js dependencies - "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + # Configure Git + - git config core.quotepath false # Build - hugo --gc --minify --baseURL ${CI_PAGES_URL} # Compress diff --git a/content/en/host-and-deploy/host-on-netlify/index.md b/content/en/host-and-deploy/host-on-netlify/index.md index f3601331a..4c89a6c1e 100644 --- a/content/en/host-and-deploy/host-on-netlify/index.md +++ b/content/en/host-and-deploy/host-on-netlify/index.md @@ -113,21 +113,23 @@ Create a new file named netlify.toml in the root of your project directory. In i ```toml {file="netlify.toml"} [build.environment] -HUGO_VERSION = "0.144.2" +GO_VERSION = "1.24" +HUGO_VERSION = "0.146.7" NODE_VERSION = "22" TZ = "America/Los_Angeles" [build] publish = "public" -command = "hugo --gc --minify" +command = "git config core.quotepath false && hugo --gc --minify" ``` If your site requires Dart Sass to transpile Sass to CSS, the configuration file should look something like this: ```toml {file="netlify.toml"} [build.environment] -HUGO_VERSION = "0.144.2" -DART_SASS_VERSION = "1.85.0" +DART_SASS_VERSION = "1.87.0" +GO_VERSION = "1.24" +HUGO_VERSION = "0.146.7" NODE_VERSION = "22" TZ = "America/Los_Angeles" @@ -138,6 +140,7 @@ command = """\ tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \ rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ + git config core.quotepath false && \ hugo --gc --minify \ """ ``` diff --git a/content/en/installation/linux.md b/content/en/installation/linux.md index 731cfce4c..591bf0818 100644 --- a/content/en/installation/linux.md +++ b/content/en/installation/linux.md @@ -30,17 +30,33 @@ To install the extended edition of Hugo: sudo snap install hugo ``` -To enable or revoke access to removable media: +To control automatic updates: ```sh +# disable automatic updates +sudo snap refresh --hold hugo + +# enable automatic updates +sudo snap refresh --unhold hugo +``` + +To control access to removable media: + +```sh +# allow access sudo snap connect hugo:removable-media + +# revoke access sudo snap disconnect hugo:removable-media ``` -To enable or revoke access to SSH keys: +To control access to SSH keys: ```sh +# allow access sudo snap connect hugo:ssh-keys + +# revoke access sudo snap disconnect hugo:ssh-keys ``` diff --git a/content/en/news/_content.gotmpl b/content/en/news/_content.gotmpl index f979c9adc..af3cf47ed 100644 --- a/content/en/news/_content.gotmpl +++ b/content/en/news/_content.gotmpl @@ -23,7 +23,8 @@ "dates" $dates "kind" "page" "params" $params - "path" .name + "path" (strings.Replace .name "." "-") + "slug" .name "title" (printf "Release %s" .name) }} {{ $.AddPage $page }} diff --git a/content/en/quick-reference/glossary/iana.md b/content/en/quick-reference/glossary/iana.md new file mode 100644 index 000000000..89497f76a --- /dev/null +++ b/content/en/quick-reference/glossary/iana.md @@ -0,0 +1,6 @@ +--- +title: IANA +reference: https://www.iana.org/about +--- + +_IANA_ is an abbreviation for the Internet Assigned Numbers Authority, a non-profit organization that manages the allocation of global IP addresses, autonomous system numbers, DNS root zone, media types, and other Internet Protocol-related resources. diff --git a/content/en/quick-reference/glossary/utc.md b/content/en/quick-reference/glossary/utc.md new file mode 100644 index 000000000..a4627be5a --- /dev/null +++ b/content/en/quick-reference/glossary/utc.md @@ -0,0 +1,6 @@ +--- +title: UTC +reference: https://en.wikipedia.org/wiki/Coordinated_Universal_Time +--- + +_UTC_ is an abbreviation for Coordinated Universal Time, the primary time standard used worldwide to regulate clocks and time. It is the basis for civil time and time zones across the globe. diff --git a/content/en/shortcodes/ref.md b/content/en/shortcodes/ref.md index 2f821254c..a52c2bf6e 100755 --- a/content/en/shortcodes/ref.md +++ b/content/en/shortcodes/ref.md @@ -10,7 +10,7 @@ keywords: [] > To override Hugo's embedded `ref` shortcode, copy the [source code] to a file with the same name in the `layouts/shortcodes` directory. > [!note] -> When working with the Markdown [content format], this shortcode has become largely redundant. Its functionality is now primarily handled by [link render hooks], specifically the embedded one provided by Hugo. This hook effectively addresses all the use cases previously covered by this shortcode. +> When working with Markdown, this shortcode is obsolete. Instead, use a [link render hook] that resolves the link destination using the `GetPage` method on the `Page` object. You can either create your own, or simply enable the [embedded link render hook]. The embedded link render hook is automatically enabled for multilingual single-host projects. ## Usage @@ -56,6 +56,7 @@ Rendered: {{% include "_common/ref-and-relref-error-handling.md" %}} [content format]: /content-management/formats/ -[link render hooks]: /render-hooks/images/#default +[embedded link render hook]: /render-hooks/links/#default +[link render hook]: /render-hooks/links/ [Markdown notation]: /content-management/shortcodes/#notation -[source code]: {{% eturl ref %}} +[source code]: {{% eturl relref %}} diff --git a/content/en/shortcodes/relref.md b/content/en/shortcodes/relref.md index 5b413b87e..219eae81a 100755 --- a/content/en/shortcodes/relref.md +++ b/content/en/shortcodes/relref.md @@ -10,7 +10,7 @@ keywords: [] > To override Hugo's embedded `relref` shortcode, copy the [source code] to a file with the same name in the `layouts/shortcodes` directory. > [!note] -> When working with the Markdown [content format], this shortcode has become largely redundant. Its functionality is now primarily handled by [link render hooks], specifically the embedded one provided by Hugo. This hook effectively addresses all the use cases previously covered by this shortcode. +> When working with Markdown, this shortcode is obsolete. Instead, use a [link render hook] that resolves the link destination using the `GetPage` method on the `Page` object. You can either create your own, or simply enable the [embedded link render hook]. The embedded link render hook is automatically enabled for multilingual single-host projects. ## Usage @@ -56,6 +56,7 @@ Rendered: {{% include "_common/ref-and-relref-error-handling.md" %}} [content format]: /content-management/formats/ -[link render hooks]: /render-hooks/links/ +[embedded link render hook]: /render-hooks/links/#default +[link render hook]: /render-hooks/links/ [Markdown notation]: /content-management/shortcodes/#notation [source code]: {{% eturl relref %}} diff --git a/content/en/shortcodes/vimeo.md b/content/en/shortcodes/vimeo.md index c354eefe0..1164ce997 100755 --- a/content/en/shortcodes/vimeo.md +++ b/content/en/shortcodes/vimeo.md @@ -29,19 +29,27 @@ Hugo renders this to: ## Arguments +id +: (string) The video `id`. Optional if the `id` is provided as a positional argument as shown in the example above. + +allowFullScreen +: {{< new-in 0.146.0 />}} +: (`bool`) Whether the `iframe` element can activate full screen mode. Default is `true`. + class : (`string`) The `class` attribute of the wrapping `div` element. Adding one or more CSS classes disables inline styling. -id -: (`string`) The `id` of the Vimeo video +loading +: {{< new-in 0.146.0 />}} +: (`string`) The loading attribute of the `iframe` element, either `eager` or `lazy`. Default is `eager`. title : (`string`) The `title` attribute of the `iframe` element. -If you provide a `class` or `title` you must use a named parameter for the `id`. +Here's an example using some of the available arguments: ```text -{{}} +{{}} ``` ## Privacy diff --git a/content/en/shortcodes/youtube.md b/content/en/shortcodes/youtube.md index 18c5ae6c2..ed3cf0632 100755 --- a/content/en/shortcodes/youtube.md +++ b/content/en/shortcodes/youtube.md @@ -70,7 +70,7 @@ start title : (`string`) The `title` attribute of the `iframe` element. Defaults to "YouTube video". -Example using some of the above: +Here's an example using some of the available arguments: ```text {{}} diff --git a/content/en/templates/embedded.md b/content/en/templates/embedded.md index 198136393..ecfd90514 100644 --- a/content/en/templates/embedded.md +++ b/content/en/templates/embedded.md @@ -1,6 +1,6 @@ --- -title: Embedded templates -description: Hugo provides embedded templates for common use cases. +title: Embedded partial templates +description: Hugo provides embedded partial templates for common use cases. categories: [] keywords: [] weight: 170 @@ -145,6 +145,10 @@ Various optional metadata can also be set: If using YouTube this will produce a og:video tag like ``. Use the `https://youtu.be/` format with YouTube videos (example: `https://youtu.be/qtIqKaDlqXo`). +## Pagination + +See [details](/templates/pagination/). + ## Schema > [!note] diff --git a/content/en/templates/partial.md b/content/en/templates/partial.md index 8493a4674..7ff2d9594 100644 --- a/content/en/templates/partial.md +++ b/content/en/templates/partial.md @@ -49,7 +49,7 @@ As shown in the above example directory structure, you can nest your directories ### Variable scoping -The second argument in a partial call is the variable being passed down. The above examples are passing the `.`, which tells the template receiving the partial to apply the current [context][context]. +The second argument in a partial call is the variable being passed down. The above examples are passing the dot (`.`), which tells the template receiving the partial to apply the current [context][context]. This means the partial will *only* be able to access those variables. The partial is isolated and cannot access the outer scope. From within the partial, `$.Var` is equivalent to `.Var`. diff --git a/content/en/templates/shortcode.md b/content/en/templates/shortcode.md index 711d342cb..3ed573651 100644 --- a/content/en/templates/shortcode.md +++ b/content/en/templates/shortcode.md @@ -329,7 +329,7 @@ You can use the `HasShortcode` method in your base template to conditionally loa [`with`]: /functions/go-template/with/ [content management]: /content-management/shortcodes/ [embedded shortcodes]: /shortcodes/ -[GitHub]: https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates/shortcodes +[GitHub]: https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates/_shortcodes [introduction to templating]: /templates/introduction/ [Markdown notation]: /content-management/shortcodes/#markdown-notation [named or positional]: /content-management/shortcodes/#arguments diff --git a/content/en/troubleshooting/inspection.md b/content/en/troubleshooting/inspection.md index dc662243a..ea3c097f9 100644 --- a/content/en/troubleshooting/inspection.md +++ b/content/en/troubleshooting/inspection.md @@ -34,6 +34,11 @@ Use the [`printf`] function (render) or [`warnf`] function (log to console) to i {{ printf "%[1]v (%[1]T)" $value }} → 42 (int) ``` +{{< new-in 0.146.0 />}} + +Use the [`templates.Current`] function to visually mark template execution boundaries or to display the template call stack. + [`debug.Dump`]: /functions/debug/dump/ [`printf`]: /functions/fmt/printf/ [`warnf`]: /functions/fmt/warnf/ +[`templates.Current`]: /functions/templates/current/ diff --git a/data/embedded_template_urls.toml b/data/embedded_template_urls.toml index f75b14f12..b2a796cd1 100644 --- a/data/embedded_template_urls.toml +++ b/data/embedded_template_urls.toml @@ -4,39 +4,39 @@ # BaseURL 'base_url' = 'https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates' -# Templates -'alias' = 'alias.html' -'disqus' = 'disqus.html' -'google_analytics' = 'google_analytics.html' -'opengraph' = 'opengraph.html' -'pagination' = 'pagination.html' -'robots' = '_default/robots.txt' -'rss' = '_default/rss.xml' -'schema' = 'schema.html' -'sitemap' = '_default/sitemap.xml' -'sitemapindex' = '_default/sitemapindex.xml' -'twitter_cards' = 'twitter_cards.html' +# Partials +'disqus' = '_partials/disqus.html' +'google_analytics' = '_partials/google_analytics.html' +'opengraph' = '_partials/opengraph.html' +'pagination' = '_partials/pagination.html' +'schema' = '_partials/schema.html' +'twitter_cards' = '_partials/twitter_cards.html' # Render hooks -'render-codeblock-goat' = '_default/_markup/render-codeblock-goat.html' -'render-image' = '_default/_markup/render-image.html' -'render-link' = '_default/_markup/render-link.html' -'render-table' = '_default/_markup/render-table.html' +'render-codeblock-goat' = '_markup/render-codeblock-goat.html' +'render-image' = '_markup/render-image.html' +'render-link' = '_markup/render-link.html' +'render-table' = '_markup/render-table.html' # Shortcodes -'details' = 'shortcodes/details.html' -'figure' = 'shortcodes/figure.html' -'gist' = 'shortcodes/gist.html' -'highlight' = 'shortcodes/highlight.html' -'instagram' = 'shortcodes/instagram.html' -'param' = 'shortcodes/param.html' -'qr' = 'shortcodes/qr.html' -'ref' = 'shortcodes/ref.html' -'relref' = 'shortcodes/relref.html' -'twitter' = 'shortcodes/twitter.html' -'twitter_simple' = 'shortcodes/twitter_simple.html' -'vimeo' = 'shortcodes/vimeo.html' -'vimeo_simple' = 'shortcodes/vimeo_simple.html' -'x' = 'shortcodes/x.html' -'x_simple' = 'shortcodes/x_simple.html' -'youtube' = 'shortcodes/youtube.html' +'details' = '_shortcodes/details.html' +'figure' = '_shortcodes/figure.html' +'gist' = '_shortcodes/gist.html' +'highlight' = '_shortcodes/highlight.html' +'instagram' = '_shortcodes/instagram.html' +'param' = '_shortcodes/param.html' +'qr' = '_shortcodes/qr.html' +'ref' = '_shortcodes/ref.html' +'relref' = '_shortcodes/relref.html' +'vimeo' = '_shortcodes/vimeo.html' +'vimeo_simple' = '_shortcodes/vimeo_simple.html' +'x' = '_shortcodes/x.html' +'x_simple' = '_shortcodes/x_simple.html' +'youtube' = '_shortcodes/youtube.html' + +# Other +'alias' = 'alias.html' +'robots' = 'robots.txt' +'rss' = 'rss.xml' +'sitemap' = 'sitemap.xml' +'sitemapindex' = 'sitemapindex.xml' diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html deleted file mode 100644 index 98019e12d..000000000 --- a/layouts/_default/_markup/render-blockquote.html +++ /dev/null @@ -1,33 +0,0 @@ -{{- if eq .Type "alert" }} - {{- $alerts := dict - "caution" (dict "color" "red" "icon" "exclamation-triangle") - "important" (dict "color" "blue" "icon" "exclamation-circle") - "note" (dict "color" "blue" "icon" "information-circle") - "tip" (dict "color" "green" "icon" "light-bulb") - "warning" (dict "color" "orange" "icon" "exclamation-triangle") - }} - - {{- $alertTypes := slice }} - {{- range $k, $_ := $alerts }} - {{- $alertTypes = $alertTypes | append $k }} - {{- end }} - {{- $alertTypes = $alertTypes | sort }} - - {{- $alertType := strings.ToLower .AlertType }} - {{- if in $alertTypes $alertType }} - {{- partial "layouts/blocks/alert.html" (dict - "color" (or ((index $alerts $alertType).color) "blue") - "icon" (or ((index $alerts $alertType).icon) "information-circle") - "text" .Text - "title" .AlertTitle - "class" .Attributes.class - ) - }} - {{- else }} - {{- errorf `Invalid blockquote alert type. Received %s. Expected one of %s (case-insensitive). See %s.` .AlertType (delimit $alertTypes ", " ", or ") .Page.String }} - {{- end }} -{{- else }} -
- {{ .Text }} -
-{{- end }} diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html deleted file mode 100644 index 13725ffcd..000000000 --- a/layouts/_default/_markup/render-codeblock.html +++ /dev/null @@ -1,98 +0,0 @@ -{{/* prettier-ignore-start */}} -{{/* -Renders a highlighted code block using the given options and attributes. - -In addition to the options available to the transform.Highlight function, you -may also specify the following parameters: - -@param {bool} [copy=false] Whether to display a copy-to-clipboard button. -@param {string} [file] The file name to display above the rendered code. -@param {bool} [details=false] Whether to wrap the highlighted code block within a details element. -@param {bool} [open=false] Whether to initially display the content of the details element. -@param {string} [summary=Details] The content of the details summary element rendered from Markdown to HTML. - -@returns {template.HTML} - -@examples - - ```go - fmt.Println("Hello world!") - ``` - - ```go {linenos=true file="layouts/index.html" copy=true} - fmt.Println("Hello world!") - ``` -*/}} -{{/* prettier-ignore-end */}} - -{{- $copy := false }} -{{- $file := or .Attributes.file "" }} -{{- $details := false }} -{{- $open := "" }} -{{- $summary := or .Attributes.summary "Details" | .Page.RenderString }} -{{- $ext := strings.TrimPrefix "." (path.Ext $file) }} -{{- $lang := or .Type $ext "text" }} -{{- if in (slice "html" "gotmpl") $lang }} - {{- $lang = "go-html-template" }} -{{- end }} -{{- if eq $lang "md" }} - {{- $lang = "text" }} -{{- end }} - -{{- with .Attributes.copy }} - {{- if in (slice true "true" 1) . }} - {{- $copy = true }} - {{- else if in (slice false "false" 0) . }} - {{- $copy = false }} - {{- end }} -{{- end }} - -{{- with .Attributes.details }} - {{- if in (slice true "true" 1) . }} - {{- $details = true }} - {{- else if in (slice false "false" 0) . }} - {{- $details = false }} - {{- end }} -{{- end }} - -{{- with .Attributes.open }} - {{- if in (slice true "true" 1) . }} - {{- $open = "open" }} - {{- else if in (slice false "false" 0) . }} - {{- $open = "" }} - {{- end }} -{{- end }} - -{{- if $details }} -
- {{ $summary }} -{{- end }} - -
- {{- $fileSelectClass := "select-none" }} - {{- if $copy }} - {{- $fileSelectClass = "select-text" }} - - - - {{- end }} - {{- with $file }} -
- {{ . }} -
- {{- end }} - -
- {{- transform.Highlight (strings.TrimSpace .Inner) $lang .Options }} -
-
- -{{- if $details }} -
-{{- end }} diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html deleted file mode 100644 index 88e3cbee5..000000000 --- a/layouts/_default/_markup/render-link.html +++ /dev/null @@ -1,320 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}} - -{{- /* -Copyright 2025 Veriphor LLC - -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at - -https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -*/}} - -{{- /* -This render hook resolves internal destinations by looking for a matching: - - 1. Content page - 2. Page resource (a file in the current page bundle) - 3. Section resource (a file in the current section) - 4. Global resource (a file in the assets directory) - -It skips the section resource lookup if the current page is a leaf bundle. - -External destinations are not modified. - -You must place global resources in the assets directory. If you have placed -your resources in the static directory, and you are unable or unwilling to move -them, you must mount the static directory to the assets directory by including -both of these entries in your site configuration: - - [[module.mounts]] - source = 'assets' - target = 'assets' - - [[module.mounts]] - source = 'static' - target = 'assets' - -By default, if this render hook is unable to resolve a destination, including a -fragment if present, it passes the destination through without modification. To -emit a warning or error, set the error level in your site configuration: - - [params.render_hooks.link] - errorLevel = 'warning' # ignore (default), warning, or error (fails the build) - -When you set the error level to warning, and you are in a development -environment, you can visually highlight broken internal links: - - [params.render_hooks.link] - errorLevel = 'warning' # ignore (default), warning, or error (fails the build) - highlightBroken = true # true or false (default) - -This will add a "broken" class to anchor elements with invalid src attributes. -Add a rule to your CSS targeting the broken links: - - a.broken { - background: #ff0; - border: 2px solid #f00; - padding: 0.1em 0.2em; - } - -This render hook may be unable to resolve destinations created with the ref and -relref shortcodes. Unless you set the error level to ignore you should not use -either of these shortcodes in conjunction with this render hook. - -@context {string} Destination The link destination. -@context {page} Page A reference to the page containing the link. -@context {string} PlainText The link description as plain text. -@context {string} Text The link description. -@context {string} Title The link title. - -@returns {template.html} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- /* Initialize. */}} -{{- $renderHookName := "link" }} - -{{- /* Verify minimum required version. */}} -{{- $minHugoVersion := "0.141.0" }} -{{- if lt hugo.Version $minHugoVersion }} - {{- errorf "The %q render hook requires Hugo v%s or later." $renderHookName $minHugoVersion }} -{{- end }} - -{{- /* Error level when unable to resolve destination: ignore, warning, or error. */}} -{{- $errorLevel := or site.Params.render_hooks.link.errorLevel "ignore" | lower }} - -{{- /* If true, adds "broken" class to broken links. Applicable in development environment when errorLevel is warning. */}} -{{- $highlightBrokenLinks := or site.Params.render_hooks.link.highlightBroken false }} - -{{- /* Validate error level. */}} -{{- if not (in (slice "ignore" "warning" "error") $errorLevel) }} - {{- errorf "The %q render hook is misconfigured. The errorLevel %q is invalid. Please check your site configuration." $renderHookName $errorLevel }} -{{- end }} - -{{- /* Determine content path for warning and error messages. */}} -{{- $contentPath := .Page.String }} - -{{- /* Parse destination. */}} -{{- $u := urls.Parse .Destination }} - -{{- /* Set common message. */}} -{{- $msg := printf "The %q render hook was unable to resolve the destination %q in %s" $renderHookName $u.String $contentPath }} - -{{- /* Set attributes for anchor element. */}} -{{- $attrs := dict "href" $u.String }} -{{- if eq $u.String "g" }} - {{- /* Destination is a glossary term. */}} - {{- $ctx := dict - "contentPath" $contentPath - "errorLevel" $errorLevel - "renderHookName" $renderHookName - "text" .Text - }} - {{- $attrs = partial "inline/h-rh-l/get-glossary-link-attributes.html" $ctx }} -{{- else if $u.IsAbs }} - {{- /* Destination is a remote resource. */}} - {{- $attrs = merge $attrs (dict "rel" "external") }} -{{- else }} - {{- with $u.Path }} - {{- with $p := or ($.PageInner.GetPage .) ($.PageInner.GetPage (strings.TrimRight "/" .)) }} - {{- /* Destination is a page. */}} - {{- $href := .RelPermalink }} - {{- with $u.RawQuery }} - {{- $href = printf "%s?%s" $href . }} - {{- end }} - {{- with $u.Fragment }} - {{- $ctx := dict - "contentPath" $contentPath - "errorLevel" $errorLevel - "page" $p - "parsedURL" $u - "renderHookName" $renderHookName - }} - {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} - {{- $href = printf "%s#%s" $href . }} - {{- end }} - {{- $attrs = dict "href" $href }} - {{- else with $.PageInner.Resources.Get $u.Path }} - {{- /* Destination is a page resource; drop query and fragment. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else with (and (ne $.Page.BundleType "leaf") ($.Page.CurrentSection.Resources.Get $u.Path)) }} - {{- /* Destination is a section resource, and current page is not a leaf bundle. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else with resources.Get $u.Path }} - {{- /* Destination is a global resource; drop query and fragment. */}} - {{- $attrs = dict "href" .RelPermalink }} - {{- else }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- if and $highlightBrokenLinks hugo.IsDevelopment }} - {{- $attrs = merge $attrs (dict "class" "broken") }} - {{- end }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- else }} - {{- with $u.Fragment }} - {{- /* Destination is on the same page; prepend relative permalink. */}} - {{- $ctx := dict - "contentPath" $contentPath - "errorLevel" $errorLevel - "page" $.Page - "parsedURL" $u - "renderHookName" $renderHookName - }} - {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} - {{- $attrs = dict "href" (printf "%s#%s" $.Page.RelPermalink .) }} - {{- else }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- if and $highlightBrokenLinks hugo.IsDevelopment }} - {{- $attrs = merge $attrs (dict "class" "broken") }} - {{- end }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} - -{{- /* Render anchor element. */ -}} -{{ .Text }} - -{{- define "partials/inline/h-rh-l/validate-fragment.html" }} - {{- /* - Validates the fragment portion of a link destination. - - @context {string} contentPath The page containing the link. - @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 {struct} parsedURL The link destination parsed by urls.Parse. - @context {string} renderHookName The name of the render hook. - */}} - - {{- /* Initialize. */}} - {{- $contentPath := .contentPath }} - {{- $errorLevel := .errorLevel }} - {{- $p := .page }} - {{- $u := .parsedURL }} - {{- $renderHookName := .renderHookName }} - - {{- /* Validate. */}} - {{- with $u.Fragment }} - {{- if $p.Fragments.Identifiers.Contains . }} - {{- if gt ($p.Fragments.Identifiers.Count .) 1 }} - {{- $msg := printf "The %q render hook detected duplicate heading IDs %q in %s" $renderHookName . $contentPath }} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- else }} - {{- /* Determine target path for warning and error message. */}} - {{- $targetPath := "" }} - {{- with $p.File }} - {{- $targetPath = .Path }} - {{- else }} - {{- $targetPath = .Path }} - {{- end }} - {{- /* Set common message. */}} - {{- $msg := printf "The %q render hook was unable to find heading ID %q in %s. See %s" $renderHookName . $targetPath $contentPath }} - {{- if eq $targetPath $contentPath }} - {{- $msg = printf "The %q render hook was unable to find heading ID %q in %s" $renderHookName . $targetPath }} - {{- end }} - {{- /* Throw warning or error. */}} - {{- if eq $errorLevel "warning" }} - {{- warnf $msg }} - {{- else if eq $errorLevel "error" }} - {{- errorf $msg }} - {{- end }} - {{- end }} - {{- end }} -{{- end }} - -{{- define "partials/inline/h-rh-l/get-glossary-link-attributes.html" }} - {{- /* - Returns the anchor element attributes for a link to the given glossary term. - - It first checks for the existence of a glossary page for the given term. If - no page is found, it then checks for a glossary page for the singular form of - the term. If neither page exists it throws a warning or error dependent on - the errorLevel setting - - The returned href attribute does not point to the glossary term page. - Instead, via its fragment, it points to an entry on the glossary page. - - @context {string} contentPath The page containing the link. - @context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error. - @context {string} renderHookName The name of the render hook. - @context {string} text The link text. - */}} - - {{- /* Get context.. */}} - {{- $contentPath := .contentPath }} - {{- $errorLevel := .errorLevel }} - {{- $renderHookName := .renderHookName }} - {{- $text := .text | transform.Plainify | strings.ToLower }} - - {{- /* Initialize. */}} - {{- $glossaryPath := "/quick-reference/glossary" }} - {{- $termGiven := $text }} - {{- $termActual := "" }} - {{- $termSingular := inflect.Singularize $termGiven }} - - {{- /* Verify that the glossary page exists. */}} - {{- $glossaryPage := site.GetPage $glossaryPath }} - {{- if not $glossaryPage }} - {{- errorf "The %q render hook was unable to find %s: see %s" $renderHookName $glossaryPath $contentPath }} - {{- end }} - - {{- /* There's a better way to handle this, but it works for now. */}} - {{- $cheating := dict - "chaining" "chain" - "localize" "localization" - "localized" "localization" - "paginating" "paginate" - "walking" "walk" - "ci/cd" "cicd" - }} - - {{- /* Verify that a glossary term page exists for the given term. */}} - {{- if site.GetPage (urls.JoinPath $glossaryPath ($termGiven | urlize)) }} - {{- $termActual = $termGiven }} - {{- else if site.GetPage (urls.JoinPath $glossaryPath ($termSingular | urlize)) }} - {{- $termActual = $termSingular }} - {{- else }} - {{- $termToTest := index $cheating $termGiven }} - {{- if site.GetPage (urls.JoinPath $glossaryPath ($termToTest | urlize)) }} - {{- $termActual = $termToTest }} - {{- end }} - {{- end }} - - {{- if not $termActual }} - {{- errorf "The %q render hook was unable to find a glossary page for either the singular or plural form of the term %q: see %s" $renderHookName $termGiven $contentPath }} - {{- end }} - - {{- /* Create the href attribute. */}} - {{- $href := "" }} - {{- if $termActual }} - {{- $href = fmt.Printf "%s#%s" $glossaryPage.RelPermalink (anchorize $termActual) }} - {{- end }} - - {{- return (dict "href" $href) }} -{{- end -}} diff --git a/layouts/_default/_markup/render-passthrough.html b/layouts/_default/_markup/render-passthrough.html deleted file mode 100644 index 0ed001133..000000000 --- a/layouts/_default/_markup/render-passthrough.html +++ /dev/null @@ -1,9 +0,0 @@ -{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }} -{{- with try (transform.ToMath .Inner $opts) }} - {{- with .Err }} - {{ errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }} - {{- else }} - {{- .Value }} - {{- $.Page.Store.Set "hasMath" true }} - {{- end }} -{{- end -}} diff --git a/layouts/_default/_markup/render-table.html b/layouts/_default/_markup/render-table.html deleted file mode 100644 index 7f3a88601..000000000 --- a/layouts/_default/_markup/render-table.html +++ /dev/null @@ -1,31 +0,0 @@ -
- - - {{- range .THead }} - - {{- range . }} - - {{- end }} - - {{- end }} - - - {{- range .TBody }} - - {{- range . }} - - {{- end }} - - {{- end }} - -
- {{- .Text -}} -
- {{- .Text -}} -
-
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html deleted file mode 100644 index 1f4952146..000000000 --- a/layouts/_default/baseof.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - {{ .Title }} - - - - {{ partial "layouts/head/head-js.html" . }} - {{ with (templates.Defer (dict "key" "global")) }} - {{ $t := debug.Timer "tailwindcss" }} - {{ with resources.Get "css/styles.css" }} - {{ $opts := dict - "inlineImports" true - "minify" (not hugo.IsDevelopment) - }} - {{ with . | css.TailwindCSS $opts }} - {{ partial "helpers/linkcss.html" (dict "r" .) }} - {{ end }} - {{ end }} - {{ $t.Stop }} - {{ end }} - {{ $noop := .WordCount }} - {{ if .Page.Store.Get "hasMath" }} - - {{ end }} - {{ partial "layouts/head/head.html" . }} - - - {{ partial "layouts/hooks/body-start.html" . }} - {{/* Layout. */}} - {{ block "header" . }} - {{ partial "layouts/header/header.html" . }} - {{ end }} - {{ block "hero" . }} - {{ end }} -
-
- {{ partial "layouts/hooks/body-main-start.html" . }} - {{ block "main" . }}{{ end }} -
- {{ block "rightsidebar" . }} - - {{ end }} -
- {{/* Common icons. */}} - {{ partial "layouts/icons.html" . }} - {{/* Common templates. */}} - {{ partial "layouts/templates.html" . }} - {{/* Footer. */}} - {{ block "footer" . }} - {{ partial "layouts/footer.html" . }} - {{ end }} - {{ partial "layouts/hooks/body-end.html" . }} - - diff --git a/layouts/_default/list.html b/layouts/_default/list.html deleted file mode 100644 index b049b6da9..000000000 --- a/layouts/_default/list.html +++ /dev/null @@ -1,69 +0,0 @@ -{{ define "main" }} - {{ $pages := "" }} - {{ if .IsPage }} - {{/* We currently have a slightly odd content structure with no top level /docs section. */}} - {{ $pages = .CurrentSection.Pages }} - {{ else }} - {{ $pages = .Pages }} - {{ if eq .Section "news" }} - {{ $pages = $pages.ByPublishDate.Reverse }} - {{ end }} - {{ end }} - - -
- {{ partial "layouts/docsheader.html" . }} - -
-{{ end }} - -{{ define "rightsidebar" }} - {{ printf "%c" '\u00A0' }} -{{ end }} diff --git a/layouts/_default/list.rss.xml b/layouts/_default/list.rss.xml deleted file mode 100644 index 90fa22148..000000000 --- a/layouts/_default/list.rss.xml +++ /dev/null @@ -1,33 +0,0 @@ -{{- printf "" | safeHTML }} - - - Hugo News - Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility. - {{ .Permalink }} - Hugo {{ hugo.Version }} - {{ or site.Language.LanguageCode site.Language.Lang }} - {{- with site.Copyright }} - {{ . }} - {{- end }} - {{- with .OutputFormats.Get "rss" }} - {{ printf "" .Permalink .MediaType | safeHTML }} - {{- end }} - {{- $limit := cond (gt site.Config.Services.RSS.Limit 0) site.Config.Services.RSS.Limit 999 }} - {{- $pages := "" }} - {{- with site.GetPage "/news" }} - {{- $pages = .Pages.ByPublishDate.Reverse | first $limit }} - {{- else }} - {{- errorf "The list.rss.xml layout was unable to find the 'news' page." }} - {{- end }} - {{ (index $pages 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{- range $pages }} - - {{ .Title }} - {{ or .Params.permalink .Permalink }} - {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ or .Params.permalink .Permalink }} - {{ .Summary | transform.XMLEscape | safeHTML }} - - {{- end }} - - diff --git a/layouts/_default/single.html b/layouts/_default/single.html deleted file mode 100644 index 2e9e4f379..000000000 --- a/layouts/_default/single.html +++ /dev/null @@ -1,80 +0,0 @@ -{{ define "main" }} - {{ $ttop := debug.Timer "single" }} -
- {{ partial "layouts/docsheader.html" . }} -
- {{ with .Params.description }} -
- {{ . | markdownify }} -
- {{ end }} - {{ if .Params.show_publish_date }} - {{ with .PublishDate }} -

- {{ partial "layouts/date.html" . }} -

- {{ end }} - {{ end }} - {{ $t := debug.Timer "single.categories" }} - {{ $categories := .GetTerms "categories" }} - {{ with $categories }} -
- {{ range . }} - {{ $text := .LinkTitle }} - {{ $class := "" }} - {{ range (slice true false ) }} - {{ $color := partial "helpers/funcs/color-from-string.html" (dict "text" $text "dark" . "--single" "green" ) }} - - {{ $prefix := "" }} - {{ if . }} - {{ $prefix = "dark:" }} - {{ end }} - {{ $class = printf "%sbg-%s-%d %stext-%s-%d border %sborder-%s-%d" - $prefix $color.color $color.shade1 - $prefix $color.color $color.shade2 - $prefix $color.color $color.shade3 - }} - {{ end }} - - - - {{ .LinkTitle }} - - {{ end }} -
- {{ end }} - {{ $t.Stop }} - - {{ if .Params.functions_and_methods.signatures }} -
- {{- partial "docs/functions-signatures.html" . -}} - {{- partial "docs/functions-return-type.html" . -}} - {{- partial "docs/functions-aliases.html" . -}} -
- {{ end }} - {{ $t := debug.Timer "single.content" }} - {{ .Content }} - {{ $t.Stop }} - {{ $t := debug.Timer "single.page-edit" }} - {{ partial "layouts/page-edit.html" . }} - {{ $t.Stop }} -
-
- {{ $ttop.Stop }} -{{ end }} - -{{ define "rightsidebar_content" }} - {{/* in-this-section.html depends on these being reneredc first. */}} - {{ $related := partial "layouts/related.html" . }} - {{ $toc := partial "layouts/toc.html" . }} - {{ if not .Params.hide_in_this_section }} - {{ partial "layouts/in-this-section.html" . }} - {{ end }} - {{ $related }} - {{ if $.Store.Get "hasToc" }} - {{ $toc }} - {{ end }} -{{ end }} diff --git a/layouts/_markup/render-blockquote.html b/layouts/_markup/render-blockquote.html new file mode 100644 index 000000000..98019e12d --- /dev/null +++ b/layouts/_markup/render-blockquote.html @@ -0,0 +1,33 @@ +{{- if eq .Type "alert" }} + {{- $alerts := dict + "caution" (dict "color" "red" "icon" "exclamation-triangle") + "important" (dict "color" "blue" "icon" "exclamation-circle") + "note" (dict "color" "blue" "icon" "information-circle") + "tip" (dict "color" "green" "icon" "light-bulb") + "warning" (dict "color" "orange" "icon" "exclamation-triangle") + }} + + {{- $alertTypes := slice }} + {{- range $k, $_ := $alerts }} + {{- $alertTypes = $alertTypes | append $k }} + {{- end }} + {{- $alertTypes = $alertTypes | sort }} + + {{- $alertType := strings.ToLower .AlertType }} + {{- if in $alertTypes $alertType }} + {{- partial "layouts/blocks/alert.html" (dict + "color" (or ((index $alerts $alertType).color) "blue") + "icon" (or ((index $alerts $alertType).icon) "information-circle") + "text" .Text + "title" .AlertTitle + "class" .Attributes.class + ) + }} + {{- else }} + {{- errorf `Invalid blockquote alert type. Received %s. Expected one of %s (case-insensitive). See %s.` .AlertType (delimit $alertTypes ", " ", or ") .Page.String }} + {{- end }} +{{- else }} +
+ {{ .Text }} +
+{{- end }} diff --git a/layouts/_markup/render-codeblock.html b/layouts/_markup/render-codeblock.html new file mode 100644 index 000000000..13725ffcd --- /dev/null +++ b/layouts/_markup/render-codeblock.html @@ -0,0 +1,98 @@ +{{/* prettier-ignore-start */}} +{{/* +Renders a highlighted code block using the given options and attributes. + +In addition to the options available to the transform.Highlight function, you +may also specify the following parameters: + +@param {bool} [copy=false] Whether to display a copy-to-clipboard button. +@param {string} [file] The file name to display above the rendered code. +@param {bool} [details=false] Whether to wrap the highlighted code block within a details element. +@param {bool} [open=false] Whether to initially display the content of the details element. +@param {string} [summary=Details] The content of the details summary element rendered from Markdown to HTML. + +@returns {template.HTML} + +@examples + + ```go + fmt.Println("Hello world!") + ``` + + ```go {linenos=true file="layouts/index.html" copy=true} + fmt.Println("Hello world!") + ``` +*/}} +{{/* prettier-ignore-end */}} + +{{- $copy := false }} +{{- $file := or .Attributes.file "" }} +{{- $details := false }} +{{- $open := "" }} +{{- $summary := or .Attributes.summary "Details" | .Page.RenderString }} +{{- $ext := strings.TrimPrefix "." (path.Ext $file) }} +{{- $lang := or .Type $ext "text" }} +{{- if in (slice "html" "gotmpl") $lang }} + {{- $lang = "go-html-template" }} +{{- end }} +{{- if eq $lang "md" }} + {{- $lang = "text" }} +{{- end }} + +{{- with .Attributes.copy }} + {{- if in (slice true "true" 1) . }} + {{- $copy = true }} + {{- else if in (slice false "false" 0) . }} + {{- $copy = false }} + {{- end }} +{{- end }} + +{{- with .Attributes.details }} + {{- if in (slice true "true" 1) . }} + {{- $details = true }} + {{- else if in (slice false "false" 0) . }} + {{- $details = false }} + {{- end }} +{{- end }} + +{{- with .Attributes.open }} + {{- if in (slice true "true" 1) . }} + {{- $open = "open" }} + {{- else if in (slice false "false" 0) . }} + {{- $open = "" }} + {{- end }} +{{- end }} + +{{- if $details }} +
+ {{ $summary }} +{{- end }} + +
+ {{- $fileSelectClass := "select-none" }} + {{- if $copy }} + {{- $fileSelectClass = "select-text" }} + + + + {{- end }} + {{- with $file }} +
+ {{ . }} +
+ {{- end }} + +
+ {{- transform.Highlight (strings.TrimSpace .Inner) $lang .Options }} +
+
+ +{{- if $details }} +
+{{- end }} diff --git a/layouts/_markup/render-link.html b/layouts/_markup/render-link.html new file mode 100644 index 000000000..70011220e --- /dev/null +++ b/layouts/_markup/render-link.html @@ -0,0 +1,320 @@ +{{/* prettier-ignore-start */ -}} +{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}} + +{{- /* +Copyright 2025 Veriphor LLC + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. +*/}} + +{{- /* +This render hook resolves internal destinations by looking for a matching: + + 1. Content page + 2. Page resource (a file in the current page bundle) + 3. Section resource (a file in the current section) + 4. Global resource (a file in the assets directory) + +It skips the section resource lookup if the current page is a leaf bundle. + +External destinations are not modified. + +You must place global resources in the assets directory. If you have placed +your resources in the static directory, and you are unable or unwilling to move +them, you must mount the static directory to the assets directory by including +both of these entries in your site configuration: + + [[module.mounts]] + source = 'assets' + target = 'assets' + + [[module.mounts]] + source = 'static' + target = 'assets' + +By default, if this render hook is unable to resolve a destination, including a +fragment if present, it passes the destination through without modification. To +emit a warning or error, set the error level in your site configuration: + + [params.render_hooks.link] + errorLevel = 'warning' # ignore (default), warning, or error (fails the build) + +When you set the error level to warning, and you are in a development +environment, you can visually highlight broken internal links: + + [params.render_hooks.link] + errorLevel = 'warning' # ignore (default), warning, or error (fails the build) + highlightBroken = true # true or false (default) + +This will add a "broken" class to anchor elements with invalid src attributes. +Add a rule to your CSS targeting the broken links: + + a.broken { + background: #ff0; + border: 2px solid #f00; + padding: 0.1em 0.2em; + } + +This render hook may be unable to resolve destinations created with the ref and +relref shortcodes. Unless you set the error level to ignore you should not use +either of these shortcodes in conjunction with this render hook. + +@context {string} Destination The link destination. +@context {page} Page A reference to the page containing the link. +@context {string} PlainText The link description as plain text. +@context {string} Text The link description. +@context {string} Title The link title. + +@returns {template.html} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- /* Initialize. */}} +{{- $renderHookName := "link" }} + +{{- /* Verify minimum required version. */}} +{{- $minHugoVersion := "0.141.0" }} +{{- if lt hugo.Version $minHugoVersion }} + {{- errorf "The %q render hook requires Hugo v%s or later." $renderHookName $minHugoVersion }} +{{- end }} + +{{- /* Error level when unable to resolve destination: ignore, warning, or error. */}} +{{- $errorLevel := or site.Params.render_hooks.link.errorLevel "ignore" | lower }} + +{{- /* If true, adds "broken" class to broken links. Applicable in development environment when errorLevel is warning. */}} +{{- $highlightBrokenLinks := or site.Params.render_hooks.link.highlightBroken false }} + +{{- /* Validate error level. */}} +{{- if not (in (slice "ignore" "warning" "error") $errorLevel) }} + {{- errorf "The %q render hook is misconfigured. The errorLevel %q is invalid. Please check your site configuration." $renderHookName $errorLevel }} +{{- end }} + +{{- /* Determine content path for warning and error messages. */}} +{{- $contentPath := .Page.String }} + +{{- /* Parse destination. */}} +{{- $u := urls.Parse .Destination }} + +{{- /* Set common message. */}} +{{- $msg := printf "The %q render hook was unable to resolve the destination %q in %s" $renderHookName $u.String $contentPath }} + +{{- /* Set attributes for anchor element. */}} +{{- $attrs := dict "href" $u.String }} +{{- if eq $u.String "g" }} + {{- /* Destination is a glossary term. */}} + {{- $ctx := dict + "contentPath" $contentPath + "errorLevel" $errorLevel + "renderHookName" $renderHookName + "text" .Text + }} + {{- $attrs = partial "inline/h-rh-l/get-glossary-link-attributes.html" $ctx }} +{{- else if $u.IsAbs }} + {{- /* Destination is a remote resource. */}} + {{- $attrs = merge $attrs (dict "rel" "external") }} +{{- else }} + {{- with $u.Path }} + {{- with $p := or ($.PageInner.GetPage .) ($.PageInner.GetPage (strings.TrimRight "/" .)) }} + {{- /* Destination is a page. */}} + {{- $href := .RelPermalink }} + {{- with $u.RawQuery }} + {{- $href = printf "%s?%s" $href . }} + {{- end }} + {{- with $u.Fragment }} + {{- $ctx := dict + "contentPath" $contentPath + "errorLevel" $errorLevel + "page" $p + "parsedURL" $u + "renderHookName" $renderHookName + }} + {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} + {{- $href = printf "%s#%s" $href . }} + {{- end }} + {{- $attrs = dict "href" $href }} + {{- else with $.PageInner.Resources.Get $u.Path }} + {{- /* Destination is a page resource; drop query and fragment. */}} + {{- $attrs = dict "href" .RelPermalink }} + {{- else with (and (ne $.Page.BundleType "leaf") ($.Page.CurrentSection.Resources.Get $u.Path)) }} + {{- /* Destination is a section resource, and current page is not a leaf bundle. */}} + {{- $attrs = dict "href" .RelPermalink }} + {{- else with resources.Get $u.Path }} + {{- /* Destination is a global resource; drop query and fragment. */}} + {{- $attrs = dict "href" .RelPermalink }} + {{- else }} + {{- if eq $errorLevel "warning" }} + {{- warnf $msg }} + {{- if and $highlightBrokenLinks hugo.IsDevelopment }} + {{- $attrs = merge $attrs (dict "class" "broken") }} + {{- end }} + {{- else if eq $errorLevel "error" }} + {{- errorf $msg }} + {{- end }} + {{- end }} + {{- else }} + {{- with $u.Fragment }} + {{- /* Destination is on the same page; prepend relative permalink. */}} + {{- $ctx := dict + "contentPath" $contentPath + "errorLevel" $errorLevel + "page" $.Page + "parsedURL" $u + "renderHookName" $renderHookName + }} + {{- partial "inline/h-rh-l/validate-fragment.html" $ctx }} + {{- $attrs = dict "href" (printf "%s#%s" $.Page.RelPermalink .) }} + {{- else }} + {{- if eq $errorLevel "warning" }} + {{- warnf $msg }} + {{- if and $highlightBrokenLinks hugo.IsDevelopment }} + {{- $attrs = merge $attrs (dict "class" "broken") }} + {{- end }} + {{- else if eq $errorLevel "error" }} + {{- errorf $msg }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} + +{{- /* Render anchor element. */ -}} +{{ .Text }} + +{{- define "_partials/inline/h-rh-l/validate-fragment.html" }} + {{- /* + Validates the fragment portion of a link destination. + + @context {string} contentPath The page containing the link. + @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 {struct} parsedURL The link destination parsed by urls.Parse. + @context {string} renderHookName The name of the render hook. + */}} + + {{- /* Initialize. */}} + {{- $contentPath := .contentPath }} + {{- $errorLevel := .errorLevel }} + {{- $p := .page }} + {{- $u := .parsedURL }} + {{- $renderHookName := .renderHookName }} + + {{- /* Validate. */}} + {{- with $u.Fragment }} + {{- if $p.Fragments.Identifiers.Contains . }} + {{- if gt ($p.Fragments.Identifiers.Count .) 1 }} + {{- $msg := printf "The %q render hook detected duplicate heading IDs %q in %s" $renderHookName . $contentPath }} + {{- if eq $errorLevel "warning" }} + {{- warnf $msg }} + {{- else if eq $errorLevel "error" }} + {{- errorf $msg }} + {{- end }} + {{- end }} + {{- else }} + {{- /* Determine target path for warning and error message. */}} + {{- $targetPath := "" }} + {{- with $p.File }} + {{- $targetPath = .Path }} + {{- else }} + {{- $targetPath = .Path }} + {{- end }} + {{- /* Set common message. */}} + {{- $msg := printf "The %q render hook was unable to find heading ID %q in %s. See %s" $renderHookName . $targetPath $contentPath }} + {{- if eq $targetPath $contentPath }} + {{- $msg = printf "The %q render hook was unable to find heading ID %q in %s" $renderHookName . $targetPath }} + {{- end }} + {{- /* Throw warning or error. */}} + {{- if eq $errorLevel "warning" }} + {{- warnf $msg }} + {{- else if eq $errorLevel "error" }} + {{- errorf $msg }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} + +{{- define "_partials/inline/h-rh-l/get-glossary-link-attributes.html" }} + {{- /* + Returns the anchor element attributes for a link to the given glossary term. + + It first checks for the existence of a glossary page for the given term. If + no page is found, it then checks for a glossary page for the singular form of + the term. If neither page exists it throws a warning or error dependent on + the errorLevel setting + + The returned href attribute does not point to the glossary term page. + Instead, via its fragment, it points to an entry on the glossary page. + + @context {string} contentPath The page containing the link. + @context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error. + @context {string} renderHookName The name of the render hook. + @context {string} text The link text. + */}} + + {{- /* Get context.. */}} + {{- $contentPath := .contentPath }} + {{- $errorLevel := .errorLevel }} + {{- $renderHookName := .renderHookName }} + {{- $text := .text | transform.Plainify | strings.ToLower }} + + {{- /* Initialize. */}} + {{- $glossaryPath := "/quick-reference/glossary" }} + {{- $termGiven := $text }} + {{- $termActual := "" }} + {{- $termSingular := inflect.Singularize $termGiven }} + + {{- /* Verify that the glossary page exists. */}} + {{- $glossaryPage := site.GetPage $glossaryPath }} + {{- if not $glossaryPage }} + {{- errorf "The %q render hook was unable to find %s: see %s" $renderHookName $glossaryPath $contentPath }} + {{- end }} + + {{- /* There's a better way to handle this, but it works for now. */}} + {{- $cheating := dict + "chaining" "chain" + "localize" "localization" + "localized" "localization" + "paginating" "paginate" + "walking" "walk" + "ci/cd" "cicd" + }} + + {{- /* Verify that a glossary term page exists for the given term. */}} + {{- if site.GetPage (urls.JoinPath $glossaryPath ($termGiven | urlize)) }} + {{- $termActual = $termGiven }} + {{- else if site.GetPage (urls.JoinPath $glossaryPath ($termSingular | urlize)) }} + {{- $termActual = $termSingular }} + {{- else }} + {{- $termToTest := index $cheating $termGiven }} + {{- if site.GetPage (urls.JoinPath $glossaryPath ($termToTest | urlize)) }} + {{- $termActual = $termToTest }} + {{- end }} + {{- end }} + + {{- if not $termActual }} + {{- errorf "The %q render hook was unable to find a glossary page for either the singular or plural form of the term %q: see %s" $renderHookName $termGiven $contentPath }} + {{- end }} + + {{- /* Create the href attribute. */}} + {{- $href := "" }} + {{- if $termActual }} + {{- $href = fmt.Printf "%s#%s" $glossaryPage.RelPermalink (anchorize $termActual) }} + {{- end }} + + {{- return (dict "href" $href) }} +{{- end -}} diff --git a/layouts/_markup/render-passthrough.html b/layouts/_markup/render-passthrough.html new file mode 100644 index 000000000..0ed001133 --- /dev/null +++ b/layouts/_markup/render-passthrough.html @@ -0,0 +1,9 @@ +{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }} +{{- with try (transform.ToMath .Inner $opts) }} + {{- with .Err }} + {{ errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }} + {{- else }} + {{- .Value }} + {{- $.Page.Store.Set "hasMath" true }} + {{- end }} +{{- end -}} diff --git a/layouts/_markup/render-table.html b/layouts/_markup/render-table.html new file mode 100644 index 000000000..7f3a88601 --- /dev/null +++ b/layouts/_markup/render-table.html @@ -0,0 +1,31 @@ +
+ + + {{- range .THead }} + + {{- range . }} + + {{- end }} + + {{- end }} + + + {{- range .TBody }} + + {{- range . }} + + {{- end }} + + {{- end }} + +
+ {{- .Text -}} +
+ {{- .Text -}} +
+
diff --git a/layouts/_partials/docs/functions-aliases.html b/layouts/_partials/docs/functions-aliases.html new file mode 100644 index 000000000..b3a5a7607 --- /dev/null +++ b/layouts/_partials/docs/functions-aliases.html @@ -0,0 +1,12 @@ +{{- with .Params.functions_and_methods.aliases }} + {{- $label := "Alias" }} + {{- if gt (len .) 1 }} + {{- $label = "Aliases" }} + {{- end }} +

{{ $label }}

+ {{- range . }} +
+ {{- . -}} +
+ {{- end }} +{{- end -}} diff --git a/layouts/_partials/docs/functions-return-type.html b/layouts/_partials/docs/functions-return-type.html new file mode 100644 index 000000000..75c97f8d9 --- /dev/null +++ b/layouts/_partials/docs/functions-return-type.html @@ -0,0 +1,6 @@ +{{- with .Params.functions_and_methods.returnType }} +

Returns

+
+ {{- . -}} +
+{{- end -}} diff --git a/layouts/_partials/docs/functions-signatures.html b/layouts/_partials/docs/functions-signatures.html new file mode 100644 index 000000000..6fb61df8e --- /dev/null +++ b/layouts/_partials/docs/functions-signatures.html @@ -0,0 +1,12 @@ +{{- with .Params.functions_and_methods.signatures }} +

Syntax

+ {{- range . }} + {{- $signature := . }} + {{- if $.Params.function.returnType }} + {{- $signature = printf "%s ⟼ %s" . $.Params.function.returnType }} + {{- end }} +
+ {{- $signature -}} +
+ {{- end }} +{{- end -}} diff --git a/layouts/_partials/helpers/debug/list-item-metadata.html b/layouts/_partials/helpers/debug/list-item-metadata.html new file mode 100644 index 000000000..d027484b5 --- /dev/null +++ b/layouts/_partials/helpers/debug/list-item-metadata.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + +
weight: + {{ .Weight }} +
keywords: + {{ delimit (or .Keywords "") ", " }} +
categories: + {{ delimit (or .Params.categories "") ", " }} +
diff --git a/layouts/_partials/helpers/funcs/color-from-string.html b/layouts/_partials/helpers/funcs/color-from-string.html new file mode 100644 index 000000000..cd599530b --- /dev/null +++ b/layouts/_partials/helpers/funcs/color-from-string.html @@ -0,0 +1,25 @@ +{{ $colors := slice "slate" "green" "cyan" "blue" }} +{{ with .single }} + {{ $colors = slice . }} +{{ end }} + +{{ $shades := slice 300 400 500 }} +{{ if not .dark }} + {{ $shades = slice 700 800 }} +{{ end }} +{{ $hash := (hash.FNV32a .text) }} +{{ $i := mod $hash (len $colors) }} +{{ $j := mod $hash (len $shades) }} +{{ $color := index $colors $i }} +{{ $shade1 := index $shades $j }} +{{ $shade2 := 0 }} +{{ $shade3 := 0 }} +{{ if gt $shade1 500 }} + {{ $shade2 = math.Min (sub $shade1 500) 100 | int }} + {{ $shade3 = sub $shade1 100 }} +{{ else }} + {{ $shade2 = math.Max (add $shade1 500) 700 | int }} + {{ $shade3 = add $shade1 200 }} +{{ end }} +{{ $res := dict "color" $color "shade1" $shade1 "shade2" $shade2 "shade3" $shade3 }} +{{ return $res }} diff --git a/layouts/_partials/helpers/funcs/get-github-info.html b/layouts/_partials/helpers/funcs/get-github-info.html new file mode 100644 index 000000000..7e2dc89fa --- /dev/null +++ b/layouts/_partials/helpers/funcs/get-github-info.html @@ -0,0 +1,28 @@ +{{ $url := "https://api.github.com/repos/gohugoio/hugo" }} +{{ $cacheKey := print $url (now.Format "2006-01-02") }} +{{ $headers := dict }} +{{ with os.Getenv "HUGO_GH_TOKEN" }} + {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} +{{ end }} +{{ $opts := dict "headers" $headers "key" $cacheKey }} +{{ $githubRepoInfo := dict }} +{{ with try (resources.GetRemote $url $opts) }} + {{ with .Err }} + {{ warnf "Failed to get GitHub repo info: %s" . }} + {{ else with (.Value | transform.Unmarshal) }} + {{ $githubRepoInfo = dict + "html_url" .html_url + "stargazers_url" .stargazers_url + "watchers_count" .watchers_count + "stargazers_count" .stargazers_count + "forks_count" .forks_count + "contributors_url" .contributors_url + "releases_url" .releases_url + "forks_count" .forks_count + }} + {{ else }} + {{ errorf "Unable to get remote resource %q" $url }} + {{ end }} +{{ end }} + +{{ return $githubRepoInfo }} diff --git a/layouts/_partials/helpers/funcs/get-remote-data.html b/layouts/_partials/helpers/funcs/get-remote-data.html new file mode 100644 index 000000000..ed7043421 --- /dev/null +++ b/layouts/_partials/helpers/funcs/get-remote-data.html @@ -0,0 +1,24 @@ +{{/* prettier-ignore-start */ -}} +{{/* +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" }} +*/}} +{{/* prettier-ignore-end */ -}} +{{ $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 }} diff --git a/layouts/_partials/helpers/gtag.html b/layouts/_partials/helpers/gtag.html new file mode 100644 index 000000000..59bf36ba2 --- /dev/null +++ b/layouts/_partials/helpers/gtag.html @@ -0,0 +1,27 @@ +{{ with site.Config.Services.GoogleAnalytics.ID }} + + +{{ end }} diff --git a/layouts/_partials/helpers/linkcss.html b/layouts/_partials/helpers/linkcss.html new file mode 100644 index 000000000..814d2b52f --- /dev/null +++ b/layouts/_partials/helpers/linkcss.html @@ -0,0 +1,28 @@ +{{ $r := .r }} +{{ $attr := .attributes | default dict }} + +{{ if hugo.IsDevelopment }} + +{{ else }} + {{ with $r | minify | fingerprint }} + + {{ end }} +{{ end }} + +{{ define "render-attributes" }} + {{- range $k, $v := . -}} + {{- if $v -}} + {{- printf ` %s=%q` $k $v | safeHTMLAttr -}} + {{- else -}} + {{- printf ` %s` $k | safeHTMLAttr -}} + {{- end -}} + {{- end -}} +{{ end }} diff --git a/layouts/_partials/helpers/linkjs.html b/layouts/_partials/helpers/linkjs.html new file mode 100644 index 000000000..00129ad38 --- /dev/null +++ b/layouts/_partials/helpers/linkjs.html @@ -0,0 +1,15 @@ +{{ $r := .r }} +{{ $attr := .attributes | default dict }} +{{ if hugo.IsDevelopment }} + +{{ else }} + {{ with $r | fingerprint }} + + {{ end }} +{{ end }} diff --git a/layouts/_partials/helpers/picture.html b/layouts/_partials/helpers/picture.html new file mode 100644 index 000000000..4dc16c002 --- /dev/null +++ b/layouts/_partials/helpers/picture.html @@ -0,0 +1,27 @@ +{{ $image := .image }} +{{ $width := .width | default 1000 }} +{{ $width1x := div $width 2 }} +{{ $imageWebp := $image.Resize (printf "%dx webp" $width) }} +{{ $image1x := $image.Resize (printf "%dx" $width1x) }} +{{ $image1xWebp := $image.Resize (printf "%dx webp" $width1x) }} +{{ $class := .class | default "h-64 tablet:h-96 lg:h-full w-full object-cover lg:absolute" }} +{{ $loading := .loading | default "eager" }} + + + + + + + diff --git a/layouts/_partials/helpers/validation/validate-keywords.html b/layouts/_partials/helpers/validation/validate-keywords.html new file mode 100644 index 000000000..3447ec4ef --- /dev/null +++ b/layouts/_partials/helpers/validation/validate-keywords.html @@ -0,0 +1,22 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +We use the front matter keywords field to determine related content. To ensure +consistency, during site build we validate each keyword against the entries in +data/keywords.yaml. + +As of March 5, 2025, this feature is experimental, pending usability +assessment. We anticipate that the number of additions to data/keywords.yaml +will decrease over time, though the initial implementation will require some +effort. +*/}} +{{/* prettier-ignore-end */ -}} +{{- $t := debug.Timer "validateKeywords" }} +{{- $allowedKeywords := collections.Apply site.Data.keywords "strings.ToLower" "." }} +{{- range $p := site.Pages }} + {{- range .Params.keywords }} + {{- if not (in $allowedKeywords (lower .)) }} + {{- warnf "The word or phrase %q is not in the keywords data file. See %s." . $p.Page.String }} + {{- end }} + {{- end }} +{{- end }} +{{- $t.Stop }} diff --git a/layouts/_partials/layouts/blocks/alert.html b/layouts/_partials/layouts/blocks/alert.html new file mode 100644 index 000000000..45f0044d9 --- /dev/null +++ b/layouts/_partials/layouts/blocks/alert.html @@ -0,0 +1,25 @@ +{{- $title := .title | default "" }} +{{- $color := .color | default "yellow" }} +{{- $icon := .icon | default "exclamation-triangle" }} +{{- $text := .text | default "" }} +{{- $class := .class | default "mt-6 mb-8" }} +
+
+
+ + + +
+
+ {{- with $title }} +

+ {{ . }} +

+ {{- end }} +
+ {{ $text }} +
+
+
+
diff --git a/layouts/_partials/layouts/blocks/modal.html b/layouts/_partials/layouts/blocks/modal.html new file mode 100644 index 000000000..7d825c06e --- /dev/null +++ b/layouts/_partials/layouts/blocks/modal.html @@ -0,0 +1,30 @@ +
+
+ {{ .modal_button }} +
+ +
diff --git a/layouts/_partials/layouts/breadcrumbs.html b/layouts/_partials/layouts/breadcrumbs.html new file mode 100644 index 000000000..69bcf7bd5 --- /dev/null +++ b/layouts/_partials/layouts/breadcrumbs.html @@ -0,0 +1,44 @@ +{{ $documentation := site.GetPage "/documentation" }} + + + + +{{ define "breadcrumbs-arrow" }} + + + +{{ end }} diff --git a/layouts/_partials/layouts/date.html b/layouts/_partials/layouts/date.html new file mode 100644 index 000000000..2ec1450a5 --- /dev/null +++ b/layouts/_partials/layouts/date.html @@ -0,0 +1,5 @@ +{{ $humanDate := time.Format "January 2, 2006" . }} +{{ $machineDate := time.Format "2006-01-02T15:04:05-07:00" . }} + diff --git a/layouts/_partials/layouts/docsheader.html b/layouts/_partials/layouts/docsheader.html new file mode 100644 index 000000000..7e8e950f3 --- /dev/null +++ b/layouts/_partials/layouts/docsheader.html @@ -0,0 +1,9 @@ +
+ {{ partial "layouts/breadcrumbs.html" . }} + {{ if and .IsPage (not (eq .Layout "list")) }} +

+ {{ .Title }} +

+ {{ end }} +
diff --git a/layouts/_partials/layouts/explorer.html b/layouts/_partials/layouts/explorer.html new file mode 100644 index 000000000..bb6f8e96a --- /dev/null +++ b/layouts/_partials/layouts/explorer.html @@ -0,0 +1,47 @@ +{{/* This is currently not in use, but kept in case I change my mind. */}} + + +{{ define "docs-explorer-section" }} + {{ $p := .p }} + {{ $level := .level }} + {{ $pleft := $level }} + {{ if gt $level 0 }} + {{ $pleft = add $level 1 }} + {{ end }} + {{ $pl := printf "pl-%d" $pleft }} + {{ $pages := $p.Sections }} + + {{ range $pages }} + {{ $hasChildren := gt (len .Pages) 0 }} + {{ $class := cond (eq $level 0) "text-primary hover:text-primary/70" "text-gray-900 dark:text-gray-400 hover:dark:text-gray-300" }} +
  • + + {{ .LinkTitle }} + + {{ if $hasChildren }} +
      + {{ template "docs-explorer-section" (dict "p" . "level" (add $level 1)) }} +
    + {{ end }} +
  • + {{ end }} + +{{ end }} diff --git a/layouts/_partials/layouts/footer.html b/layouts/_partials/layouts/footer.html new file mode 100644 index 000000000..1b17e44e4 --- /dev/null +++ b/layouts/_partials/layouts/footer.html @@ -0,0 +1,73 @@ +
    +
    +
    + {{/* Column 1 */}} +
    +
    + By the + Hugo Authors
    +
    + + Hugo Logo + + +
    + + {{/* Sponsors */}} +
    + {{ partial "layouts/home/sponsors.html" (dict + "ctx" . + "gtag" "footer" + + ) + }} +
    +
    +
    +

    + The Hugo logos are copyright © Steve Francia 2013–{{ now.Year }}. The + Hugo Gopher is based on an original work by Renée French. +

    +
    +
    +
    diff --git a/layouts/_partials/layouts/head/head-js.html b/layouts/_partials/layouts/head/head-js.html new file mode 100644 index 000000000..d83efcd0f --- /dev/null +++ b/layouts/_partials/layouts/head/head-js.html @@ -0,0 +1,11 @@ +{{ $githubInfo := partialCached "helpers/funcs/get-github-info.html" . "-" }} +{{ $opts := dict "minify" true }} +{{ with resources.Get "js/head-early.js" | js.Build $opts }} + {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "async" "")) }} +{{ end }} +{{ with resources.Get "js/main.js" | js.Build $opts }} + {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "defer" "")) }} +{{ end }} +{{ with resources.Get "js/turbo.js" | js.Build $opts }} + {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "defer" "")) }} +{{ end }} diff --git a/layouts/_partials/layouts/head/head.html b/layouts/_partials/layouts/head/head.html new file mode 100644 index 000000000..bb27f6a24 --- /dev/null +++ b/layouts/_partials/layouts/head/head.html @@ -0,0 +1,49 @@ + +{{ hugo.Generator }} + +{{ if hugo.IsProduction }} + +{{ else }} + +{{ end }} + + + {{ with .Title }}{{ . }} |{{ end }} + {{ .Site.Title }} + + + + + + + + + + + +{{ range .AlternativeOutputFormats -}} + +{{ end -}} + + + + + + +{{ partial "opengraph/opengraph.html" . }} +{{- template "_internal/schema.html" . -}} +{{- template "_internal/twitter_cards.html" . -}} + +{{ if hugo.IsProduction }} + {{ partial "helpers/gtag.html" . }} +{{ end }} diff --git a/layouts/_partials/layouts/header/githubstars.html b/layouts/_partials/layouts/header/githubstars.html new file mode 100644 index 000000000..75db5682a --- /dev/null +++ b/layouts/_partials/layouts/header/githubstars.html @@ -0,0 +1,16 @@ +{{ with partialCached "helpers/funcs/get-github-info.html" . "-" }} + + + + + + + + {{ printf "%0.1fk" (div .stargazers_count 1000) }} + + +{{ end }} diff --git a/layouts/_partials/layouts/header/header.html b/layouts/_partials/layouts/header/header.html new file mode 100644 index 000000000..0d2e720d7 --- /dev/null +++ b/layouts/_partials/layouts/header/header.html @@ -0,0 +1,44 @@ +
    +
    + {{ with site.Home }} + HUGO + {{ end }} +
    +
    + {{ range .Site.Menus.global }} + {{ .Name }} + {{ end }} + +
    + +
    + {{/* Search. */}} + {{ partial "layouts/search/input.html" . }} +
    +
    + {{/* QR code. */}} + {{ partial "layouts/header/qr.html" . }} + {{/* Theme selector. */}} + {{ partial "layouts/header/theme.html" . }} + + {{/* Social. */}} + +
    +
    diff --git a/layouts/_partials/layouts/header/qr.html b/layouts/_partials/layouts/header/qr.html new file mode 100644 index 000000000..fea64f625 --- /dev/null +++ b/layouts/_partials/layouts/header/qr.html @@ -0,0 +1,25 @@ +{{ $t := debug.Timer "qr" }} +{{ $qr := partial "_inline/qr" (dict + "page" $ + "img_class" "w-10 bg-white view-transition-qr" ) +}} +{{ $qrBig := partial "_inline/qr" (dict "page" $ "img_class" "w-64 p-4") }} +{{ $t.Stop }} + + +{{ define "_partials/_inline/qr" }} + {{ $img_class := .img_class | default "w-10" }} + {{ with images.QR $.page.Permalink (dict "targetDir" "images/qr") }} + + QR code linking to {{ $.page.Permalink }} + {{ end }} +{{ end }} diff --git a/layouts/_partials/layouts/header/theme.html b/layouts/_partials/layouts/header/theme.html new file mode 100644 index 000000000..e0b356d1d --- /dev/null +++ b/layouts/_partials/layouts/header/theme.html @@ -0,0 +1,35 @@ +
    + +
    diff --git a/layouts/_partials/layouts/home/features.html b/layouts/_partials/layouts/home/features.html new file mode 100644 index 000000000..527c98cb1 --- /dev/null +++ b/layouts/_partials/layouts/home/features.html @@ -0,0 +1,56 @@ +{{/* icons source: https://heroicons.com/ */}} +{{ $dataTOML := ` + [[features]] + heading = "Optimized for speed" + copy = "Written in Go, optimized for speed and designed for flexibility. With its advanced templating system and fast asset pipelines, Hugo renders a large site in seconds, often less." + icon = """ + + + """ + [[features]] + heading = "Flexible framework" + copy = "With its multilingual support, and powerful taxonomy system, Hugo is widely used to create documentation sites, landing pages, corporate, government, nonprofit, education, news, event, and project sites." + icon = """ + + + """ + [[features]] + heading = "Fast assets pipeline" + copy = "Image processing (convert, resize, crop, rotate, adjust colors, apply filters, overlay text and images, and extract EXIF data), JavaScript bundling (tree shake, code splitting), Sass processing, great TailwindCSS support." + icon = """ + + + """ + [[features]] + heading = "Embedded web server" + copy = "Use Hugo's embedded web server during development to instantly see changes to content, structure, behavior, and presentation. " + icon = """ + + + """ + ` +}} +{{ $data := $dataTOML | transform.Unmarshal }} +
    +
    +
    + {{ range $data.features }} +
    +
    +
    + {{ .icon | safeHTML }} +
    + {{ .heading }} +
    +
    + {{ .copy }} +
    +
    + {{ end }} + +
    +
    +
    diff --git a/layouts/_partials/layouts/home/opensource.html b/layouts/_partials/layouts/home/opensource.html new file mode 100644 index 000000000..153c0f4ff --- /dev/null +++ b/layouts/_partials/layouts/home/opensource.html @@ -0,0 +1,111 @@ +{{ $githubInfo := partialCached "helpers/funcs/get-github-info.html" . "-" }} +
    +
    +
    +
    +

    + Open source +

    +

    + Hugo is open source and free to use. It is distributed under the + Apache 2.0 License. +

    +
    +
    +
    + + + + Popular. +
    +
    + Hugo has + {{ $githubInfo.stargazers_count | lang.FormatNumber 0 }} + stars on GitHub as of {{ now.Format "January 2, 2006" }}. + Join the crowd and hit the + Star button. +
    +
    +
    +
    + + + + Active. +
    +
    + Hugo has a large and active community. If you have questions or + need help, you can ask in the + Hugo forums. +
    +
    +
    +
    + + + + Frequent releases. +
    +
    + Hugo has a fast + release + cycle. The project is actively maintained and new features are + added regularly. +
    +
    +
    +
    +
    + {{ partial "helpers/picture.html" (dict + "image" (resources.Get "images/hugo-github-screenshot.png") + "alt" "Hugo GitHub Repository" + "width" 640 + "class" "w-full max-w-[38rem] ring-1 shadow-xl dark:shadow-gray-500 ring-gray-400/10") + }} +
    +
    diff --git a/layouts/_partials/layouts/home/sponsors.html b/layouts/_partials/layouts/home/sponsors.html new file mode 100644 index 000000000..1f391e1ec --- /dev/null +++ b/layouts/_partials/layouts/home/sponsors.html @@ -0,0 +1,44 @@ +{{ $gtag := .gtag | default "unknown" }} +{{ $gtag := .gtag | default "unknown" }} +{{ $isFooter := (eq $gtag "footer") }} +{{ $utmSource := cond $isFooter "hugofooter" "hugohome" }} +{{ $containerClass := .containerClass | default "mx-auto max-w-7xl px-6 lg:px-8" }} +{{ with .ctx.Site.Data.sponsors }} +
    +

    Hugo Sponsors

    +
    + {{ range .banners }} +
    + {{ $query_params := .query_params | default "" }} + {{ $url := .link }} + {{ if not .no_query_params }} + {{ $url = printf "%s?%s%s" .link $query_params (querify "utm_source" (.utm_source | default $utmSource ) "utm_medium" (.utm_medium | default "banner") "utm_campaign" (.utm_campaign | default "hugosponsor") "utm_content" (.utm_content | default "gohugoio")) | safeURL }} + {{ end }} + {{ $logo := resources.Get .logo }} + {{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }} + + + +
    + {{ end }} +
    +
    +{{ end }} diff --git a/layouts/_partials/layouts/hooks/body-end.html b/layouts/_partials/layouts/hooks/body-end.html new file mode 100644 index 000000000..9ffd93ba8 --- /dev/null +++ b/layouts/_partials/layouts/hooks/body-end.html @@ -0,0 +1,3 @@ +{{- if .IsHome }} + {{- partial "helpers/validation/validate-keywords.html" }} +{{- end }} diff --git a/layouts/_partials/layouts/hooks/body-main-start.html b/layouts/_partials/layouts/hooks/body-main-start.html new file mode 100644 index 000000000..b28dd21c8 --- /dev/null +++ b/layouts/_partials/layouts/hooks/body-main-start.html @@ -0,0 +1,8 @@ +{{ if or .IsSection .IsPage }} + +{{end }} diff --git a/layouts/_partials/layouts/hooks/body-start.html b/layouts/_partials/layouts/hooks/body-start.html new file mode 100644 index 000000000..3430bd846 --- /dev/null +++ b/layouts/_partials/layouts/hooks/body-start.html @@ -0,0 +1,3 @@ +{{ with resources.Get "js/body-start.js" | js.Build (dict "minify" true) }} + {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "" "")) }} +{{ end }} diff --git a/layouts/_partials/layouts/icons.html b/layouts/_partials/layouts/icons.html new file mode 100644 index 000000000..b05adef00 --- /dev/null +++ b/layouts/_partials/layouts/icons.html @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{{/* https://heroicons.com/mini exclamation-circle */}} + + + + +{{/* https://heroicons.com/mini exclamation-triangle */}} + + + + +{{/* https://heroicons.com/mini information-circle */}} + + + + +{{/* https://heroicons.com/mini light-bulb */}} + + + diff --git a/layouts/_partials/layouts/in-this-section.html b/layouts/_partials/layouts/in-this-section.html new file mode 100644 index 000000000..28e5ed7eb --- /dev/null +++ b/layouts/_partials/layouts/in-this-section.html @@ -0,0 +1,34 @@ +{{- with .CurrentSection.RegularPages }} + {{ $hasTocOrRelated := or ($.Store.Get "hasToc") ($.Store.Get "hasRelated") }} +
    +

    + In this section +

    + + +
    +{{- end }} diff --git a/layouts/_partials/layouts/page-edit.html b/layouts/_partials/layouts/page-edit.html new file mode 100644 index 000000000..6a976d11a --- /dev/null +++ b/layouts/_partials/layouts/page-edit.html @@ -0,0 +1,26 @@ +
    +
    + +
    + Last updated: + {{ .Lastmod.Format "January 2, 2006" }}{{ with .GitInfo }} + : + {{ .Subject }} ({{ .AbbreviatedHash }}) + {{ end }} +
    + + {{ with .File }} + {{ if not .IsContentAdapter }} + {{ $href := printf "%sedit/master/content/%s/%s" site.Params.ghrepo $.Lang .Path }} + + Improve this page + + {{ end }} + {{ end }} +
    diff --git a/layouts/_partials/layouts/related.html b/layouts/_partials/layouts/related.html new file mode 100644 index 000000000..0245ba771 --- /dev/null +++ b/layouts/_partials/layouts/related.html @@ -0,0 +1,22 @@ +{{- $heading := "See also" }} +{{- $related := site.Pages.Related . }} +{{- $related = $related | complement .CurrentSection.Pages | first 7 }} + +{{- with $related }} + {{ $.Store.Set "hasRelated" true }} +

    + {{ $heading }} +

    + +{{- end }} diff --git a/layouts/_partials/layouts/search/algolialogo.html b/layouts/_partials/layouts/search/algolialogo.html new file mode 100644 index 000000000..a7fc6c0ae --- /dev/null +++ b/layouts/_partials/layouts/search/algolialogo.html @@ -0,0 +1,45 @@ +
    + Search by + + + + + + + + + + +
    diff --git a/layouts/_partials/layouts/search/button.html b/layouts/_partials/layouts/search/button.html new file mode 100644 index 000000000..07c1f7335 --- /dev/null +++ b/layouts/_partials/layouts/search/button.html @@ -0,0 +1,22 @@ +{{ $textColor := "text-gray-300" }} +{{ $fillColor := "fill-slate-400 dark:fill-slate-500" }} +{{ if .standalone }} + {{ $textColor = "text-gray-800 dark:text-gray-300 " }} + {{ $fillColor = "fill-slate-500 dark:fill-slate-400" }} +{{ end }} + + + diff --git a/layouts/_partials/layouts/search/input.html b/layouts/_partials/layouts/search/input.html new file mode 100644 index 000000000..5f5ff07b9 --- /dev/null +++ b/layouts/_partials/layouts/search/input.html @@ -0,0 +1,4 @@ +
    + {{ partial "layouts/search/button.html" (dict "page" . "standalone" false) }} + {{ partial "layouts/search/results.html" . }} +
    diff --git a/layouts/_partials/layouts/search/results.html b/layouts/_partials/layouts/search/results.html new file mode 100644 index 000000000..cd9b88dc0 --- /dev/null +++ b/layouts/_partials/layouts/search/results.html @@ -0,0 +1,90 @@ + diff --git a/layouts/_partials/layouts/templates.html b/layouts/_partials/layouts/templates.html new file mode 100644 index 000000000..72b71a3d9 --- /dev/null +++ b/layouts/_partials/layouts/templates.html @@ -0,0 +1,7 @@ + diff --git a/layouts/_partials/layouts/toc.html b/layouts/_partials/layouts/toc.html new file mode 100644 index 000000000..774bc15c7 --- /dev/null +++ b/layouts/_partials/layouts/toc.html @@ -0,0 +1,46 @@ +{{ with .Fragments }} + {{ with .Headings }} +
    +

    + On this page +

    + +
    + {{ end }} +{{ end }} + +{{ define "render-toc-level" }} + {{ range .h }} + {{ if and .ID (and (ge .Level 2) (le .Level 4)) }} + {{ $indentation := "ml-0" }} + {{ if eq .Level 3 }} + {{ $indentation = "ml-2 lg:ml-3" }} + {{ else if eq .Level 4 }} + {{ $indentation = "ml-4 lg:ml-6" }} + {{ end }} + {{ $.p.Store.Set "hasToc" true }} +
  • + + {{ .Title | safeHTML }} + +
  • + {{ end }} + {{ with .Headings }} + + {{ end }} + {{ end }} +{{ end }} diff --git a/layouts/_partials/opengraph/get-featured-image.html b/layouts/_partials/opengraph/get-featured-image.html new file mode 100644 index 000000000..50ee2a44d --- /dev/null +++ b/layouts/_partials/opengraph/get-featured-image.html @@ -0,0 +1,26 @@ +{{ $images := $.Resources.ByType "image" }} +{{ $featured := $images.GetMatch "*feature*" }} +{{ if not $featured }} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} +{{ if not $featured }} + {{ $featured = resources.Get "/opengraph/gohugoio-card-base-1.png" }} + {{ $size := 80 }} + {{ $title := $.LinkTitle }} + {{ if gt (len $title) 20 }} + {{ $size = 70 }} + {{ end }} + + {{ $text := $title }} + {{ $textOptions := dict + "color" "#FFF" + "size" $size + "lineSpacing" 10 + "x" 65 "y" 80 + "font" (resources.Get "/opengraph/mulish-black.ttf") + }} + + {{ $featured = $featured | images.Filter (images.Text $text $textOptions) }} +{{ end }} + +{{ return $featured }} diff --git a/layouts/_partials/opengraph/opengraph.html b/layouts/_partials/opengraph/opengraph.html new file mode 100644 index 000000000..e32e07298 --- /dev/null +++ b/layouts/_partials/opengraph/opengraph.html @@ -0,0 +1,84 @@ + + + + + +{{- with $.Params.images -}} + {{- range first 6 . }} + + {{ end -}} +{{- else -}} + {{- $featured := partial "opengraph/get-featured-image.html" . }} + {{- with $featured -}} + + {{- else -}} + {{- with $.Site.Params.images }} + + {{ end -}} + {{- end -}} +{{- end -}} + +{{- if .IsPage }} + {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} + + {{ with .PublishDate }} + + {{ end }} + {{ with .Lastmod }} + + {{ end }} +{{- end -}} + +{{- with .Params.audio }}{{ end }} +{{- with .Params.locale }} + +{{ end }} +{{- with .Site.Params.title }} + +{{ end }} +{{- with .Params.videos }} + {{- range . }} + + {{ end }} + +{{ end }} + +{{- /* If it is part of a series, link to related articles */}} +{{- $permalink := .Permalink }} +{{- $siteSeries := .Site.Taxonomies.series }} +{{ with .Params.series }} + {{- range $name := . }} + {{- $series := index $siteSeries ($name | urlize) }} + {{- range $page := first 6 $series.Pages }} + {{- if ne $page.Permalink $permalink }} + + {{ end }} + {{- end }} + {{ end }} + +{{ end }} + +{{- /* Facebook Page Admin ID for Domain Insights */}} +{{- with site.Params.social.facebook_admin }} + +{{ end }} diff --git a/layouts/_shortcodes/chroma-lexers.html b/layouts/_shortcodes/chroma-lexers.html new file mode 100644 index 000000000..fd7130501 --- /dev/null +++ b/layouts/_shortcodes/chroma-lexers.html @@ -0,0 +1,28 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders an HTML template of Chroma lexers and their aliases. + +@example {{< chroma-lexers >}} +*/ -}} +{{/* prettier-ignore-end */ -}} +
    + + + + + + + {{- range site.Data.docs.chroma.lexers }} + + + + + {{- end }} + +
    LanguageIdentifiers
    {{ .Name }} + {{- range $k, $_ := .Aliases }} + {{- if $k }},{{ end }} + {{ . }} + {{- end }} +
    +
    diff --git a/layouts/_shortcodes/code-toggle.html b/layouts/_shortcodes/code-toggle.html new file mode 100644 index 000000000..a22c378be --- /dev/null +++ b/layouts/_shortcodes/code-toggle.html @@ -0,0 +1,120 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats. + +@param {string} [config] The section of site.Data.docs.config to render. +@param {bool} [copy=false] Whether to display a copy-to-clipboard button. +@param {string} [dataKey] The section of site.Data.docs to render. +@param {string} [file] The file name to display above the rendered code. +@param {bool} [fm=false] Whether to render the code as front matter. +@param {bool} [skipHeader=false] Whether to omit top level key(s) when rendering a section of site.Data.docs.config. + +@example {{< code-toggle file=hugo config=build />}} + +@example {{< code-toggle file=content/example.md fm="true" }} + title='Example' + draft='false + {{< /code-toggle }} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- /* Initialize. */}} +{{- $config := "" }} +{{- $copy := false }} +{{- $dataKey := "" }} +{{- $file := "" }} +{{- $fm := false }} +{{- $skipHeader := false }} + +{{- /* Get parameters. */}} +{{- $config = .Get "config" }} +{{- $dataKey = .Get "dataKey" }} +{{- $file = .Get "file" }} +{{- if in (slice "false" false 0) (.Get "copy") }} + {{- $copy = false }} +{{- else if in (slice "true" true 1) (.Get "copy") }} + {{- $copy = true }} +{{- end }} +{{- if in (slice "false" false 0) (.Get "fm") }} + {{- $fm = false }} +{{- else if in (slice "true" true 1) (.Get "fm") }} + {{- $fm = true }} +{{- end }} +{{- if in (slice "false" false 0) (.Get "skipHeader") }} + {{- $skipHeader = false }} +{{- else if in (slice "true" true 1) (.Get "skipHeader") }} + {{- $skipHeader = true }} +{{- end }} + +{{- /* Define constants. */}} +{{- $delimiters := dict "toml" "+++" "yaml" "---" }} +{{- $langs := slice "yaml" "toml" "json" }} +{{- $placeHolder := "#-hugo-placeholder-#" }} + +{{- /* Render. */}} +{{- $code := "" }} +{{- if $config }} + {{- $file = $file | default "hugo" }} + {{- $sections := (split $config ".") }} + {{- $configSection := index $.Site.Data.docs.config $sections }} + {{- $code = dict $sections $configSection }} + {{- if $skipHeader }} + {{- $code = $configSection }} + {{- end }} +{{- else if $dataKey }} + {{- $file = $file | default $dataKey }} + {{- $sections := (split $dataKey ".") }} + {{- $code = index $.Site.Data.docs $sections }} +{{- else }} + {{- $code = $.Inner }} +{{- end }} + + +
    + {{- if $copy }} + + + + {{- end }} + + {{- if $code }} + {{- range $i, $lang := $langs }} +
    + {{- $hCode := $code | transform.Remarshal . }} + {{- if and $fm (in (slice "toml" "yaml") .) }} + {{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }} + {{- end }} + {{- $hCode = $hCode | replaceRE `\n+` "\n" }} + {{- highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }} +
    + {{- end }} + {{- end }} +
    diff --git a/layouts/_shortcodes/datatable-filtered.html b/layouts/_shortcodes/datatable-filtered.html new file mode 100644 index 000000000..de8b0cf55 --- /dev/null +++ b/layouts/_shortcodes/datatable-filtered.html @@ -0,0 +1,47 @@ +{{ $package := (index .Params 0) }} +{{ $listname := (index .Params 1) }} +{{ $filter := split (index .Params 2) " " }} +{{ $filter1 := index $filter 0 }} +{{ $filter2 := index $filter 1 }} +{{ $filter3 := index $filter 2 }} + +{{ $list := (index (index .Site.Data.docs $package) $listname) }} +{{ $fields := after 3 .Params }} +{{ $list := where $list $filter1 $filter2 $filter3 }} + + +
    + + + + {{ range $fields }} + + {{ end }} + + + + {{ range $list }} + + {{ range $k, $v := . }} + {{ $.Scratch.Set $k $v }} + {{ end }} + {{ range $k, $v := $fields }} + + {{ end }} + + {{ end }} + +
    {{ . }}
    + {{ $tdContent := $.Scratch.Get . }} + {{ if eq $k 3 }} + {{ printf "%v" $tdContent | + strings.ReplaceRE `\[` "
    1. " | + strings.ReplaceRE `\s` "
    2. " | + strings.ReplaceRE `\]` "
    " | + safeHTML + }} + {{ else }} + {{ $tdContent }} + {{ end }} +
    +
    diff --git a/layouts/_shortcodes/datatable.html b/layouts/_shortcodes/datatable.html new file mode 100644 index 000000000..f135d841c --- /dev/null +++ b/layouts/_shortcodes/datatable.html @@ -0,0 +1,39 @@ +{{ $package := (index .Params 0) }} +{{ $listname := (index .Params 1) }} +{{ $list := (index (index .Site.Data.docs $package) $listname) }} +{{ $fields := after 2 .Params }} + + +
    + + + + {{ range $fields }} + {{ $s := . }} + {{ if eq $s "_key" }} + {{ $s = "type" }} + {{ end }} + + {{ end }} + + + + {{ range $k1, $v1 := $list }} + + {{ range $k2, $v2 := . }} + {{ $.Scratch.Set $k2 $v2 }} + {{ end }} + {{ range $fields }} + {{ $s := "" }} + {{ if eq . "_key" }} + {{ $s = $k1 }} + {{ else }} + {{ $s = $.Scratch.Get . }} + {{ end }} + + {{ end }} + + {{ end }} + +
    {{ $s }}
    {{ $s }}
    +
    diff --git a/layouts/_shortcodes/deprecated-in.html b/layouts/_shortcodes/deprecated-in.html new file mode 100644 index 000000000..ce2ba389e --- /dev/null +++ b/layouts/_shortcodes/deprecated-in.html @@ -0,0 +1,29 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders a callout indicating the version in which a feature was deprecated. + +Include descriptive text between the opening and closing tags, or omit the +descriptive text and call the shortcode with a self-closing tag. + +@param {string} 0 The semantic version string, with or without a leading v. + +@example {{< deprecated-in 0.144.0 />}} + +@example {{< deprecated-in 0.144.0 >}} + Some descriptive text here. + {{< /deprecated-in >}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- with $version := .Get 0 | strings.TrimLeft "vV" }} + {{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }} + {{- $inner := strings.TrimSpace $.Inner }} + {{- $text := printf "Deprecated in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }} + {{- partial "layouts/blocks/alert.html" (dict + "color" "orange" + "icon" "exclamation" + "text" $text + ) + }} +{{- else }} + {{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }} +{{- end }} diff --git a/layouts/_shortcodes/eturl.html b/layouts/_shortcodes/eturl.html new file mode 100644 index 000000000..a0237dbe0 --- /dev/null +++ b/layouts/_shortcodes/eturl.html @@ -0,0 +1,26 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders an absolute URL to the source code for an embedded template. + +Accepts either positional or named parameters, and depends on the +embedded_templates.toml file in the data directory. + +@param {string} filename The embedded template's file name, excluding extension. + +@example {{% et robots.txt %}} +@example {{% et filename=robots.txt %}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- with $filename := or (.Get "filename") (.Get 0) }} + {{- with site.Data.embedded_template_urls }} + {{- with index . $filename }} + {{- urls.JoinPath site.Data.embedded_template_urls.base_url . }} + {{- else }} + {{- errorf "The %q shortcode was unable to find a URL for the embedded template named %q. Check the name. See %s" $.Name $filename $.Position }} + {{- end }} + {{- else }} + {{- errorf "The %q shortcode was unable to find the embedded_template_urls data file in the site's data directory. See %s" $.Name $.Position }} + {{- end }} +{{- else }} + {{- errorf "The %q shortcodes requires a named or positional parameter, the file name of the embedded template, excluding its extension. See %s" .Name .Position }} +{{- end -}} diff --git a/layouts/_shortcodes/glossary-term.html b/layouts/_shortcodes/glossary-term.html new file mode 100644 index 000000000..2a45dc8cb --- /dev/null +++ b/layouts/_shortcodes/glossary-term.html @@ -0,0 +1,18 @@ +{{- /* +Renders the definition of the given glossary term. + +@param {string} (.Get 0) The glossary term. + +@example {{% glossary-term float %}} +@example {{% glossary-term "floating point" %}} +*/ -}} +{{- with .Get 0 }} + {{- $path := printf "/quick-reference/glossary/%s" (urlize .) }} + {{- with site.GetPage $path }} +{{ .RenderShortcodes }}{{/* Do not indent. */}} + {{- else }} + {{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }} + {{- end }} +{{- else }} + {{- errorf "The glossary term (%s) shortcode requires one positional parameter: see %s" $.Name $.Position }} +{{- end -}} diff --git a/layouts/_shortcodes/glossary.html b/layouts/_shortcodes/glossary.html new file mode 100644 index 000000000..7331d5c9f --- /dev/null +++ b/layouts/_shortcodes/glossary.html @@ -0,0 +1,54 @@ +{{- /* +Renders the glossary of terms. + +When you call this shortcode using the {{% %}} notation, the glossary terms are +Markdown headings (level 6) which means they are members of .Fragments. This +allows the link render hook to verify links to glossary terms. + +Yes, the terms themselves are pages, but we don't want to link to the pages, at +least not right now. Instead, we want to link to the ids rendered by this +shortcode. + +@example {{% glossary %}} +*/ -}} +{{- $path := "/quick-reference/glossary" }} +{{- with site.GetPage $path }} + + {{- /* Build and render alphabetical index. */}} + {{- $m := dict }} + {{- range $p := .Pages.ByTitle }} + {{- $k := substr .Title 0 1 | strings.ToUpper }} + {{- if index $m $k }} + {{- continue }} + {{- end }} + {{- $anchor := path.BaseName .Path | anchorize }} + {{- $m = merge $m (dict $k $anchor) }} + {{- end }} + {{- range $k, $v := $m }} +[{{ $k }}](#{{ $v }}) {{/* Do not indent. */}} + {{- end }} + + {{/* Render glossary terms. */}} + {{- range $p := .Pages.ByTitle }} +{{ .Title }}{{/* Do not indent. */}} +: {{ .RawContent | strings.TrimSpace | safeHTML }}{{/* Do not indent. */}} + {{ with .Params.reference }} + {{- $destination := "" }} + {{- with $u := urls.Parse . }} + {{- if $u.IsAbs }} + {{- $destination = $u.String }} + {{- else }} + {{- with site.GetPage $u.Path }} + {{- $destination = .RelPermalink }} + {{- else }} + {{- errorf "The %q shortcode was unable to find the reference link %s: see %s" $.Name . $p.String }} + {{- end }} + {{- end }} + {{- end }} +: See [details]({{ $destination }}).{{/* Do not indent. */}} + {{- end }} + {{ end }} + +{{- else }} + {{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}} +{{- end }} diff --git a/layouts/_shortcodes/hl.html b/layouts/_shortcodes/hl.html new file mode 100644 index 000000000..3fafcb5e8 --- /dev/null +++ b/layouts/_shortcodes/hl.html @@ -0,0 +1,14 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Returns syntax-highlighted code from the given text. + +This is useful as a terse way to highlight inline code snippets. Calling the +highlight shortcode for inline snippets is verbose. + +@example This is {{< hl python >}}inline{{< /hl >}} code. +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- $code := .Inner | strings.TrimSpace }} +{{- $lang := or (.Get 0) "go" }} +{{- $opts := dict "hl_inline" true "noClasses" true }} +{{- transform.Highlight $code $lang $opts }} diff --git a/layouts/_shortcodes/img.html b/layouts/_shortcodes/img.html new file mode 100644 index 000000000..e49afc57f --- /dev/null +++ b/layouts/_shortcodes/img.html @@ -0,0 +1,391 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders the given image using the given filter, if any. + +When using the text filter, provide the arguments in this order: + +0. The text +1. The horizontal offset, in pixels, relative to the left of the image (default 20) +2. The vertical offset, in pixels, relative to the top of the image (default 20) +3. The font size in pixels (default 64) +4. The line height (default 1.2) +5. The font color (default #ffffff) + +When using the padding filter, provide all arguments in this order: + +0. Padding top +1. Padding right +2. Padding bottom +3. Padding right +4. Canvas color + +@param {string} src The path to the image which must be a remote, page, or global resource. +@param {string} [filter] The filter to apply to the image (case-insensitive). +@param {string} [filterArgs] A comma-delimited list of arguments to pass to the filter. +@param {bool} [example=false] If true, renders a before/after example. +@param {int} [exampleWidth=384] Image width, in pixels, when rendering a before/after example. + +@example {{< img src="zion-national-park.jpg" >}} +@example {{< img src="zion-national-park.jpg" alt="Zion National Park" >}} + +@example {{< img + src="zion-national-park.jpg" + alt="Zion National Park" + filter="grayscale" + >}} + +@example {{< img + src="zion-national-park.jpg" + alt="Zion National Park" + filter="process" + filterArgs="resize 400x webp" + >}} + +@example {{< img + src="zion-national-park.jpg" + alt="Zion National Park" + filter="colorize" + filterArgs="180,50,20" + >}} + +@example {{< img + src="zion-national-park.jpg" + alt="Zion National Park" + filter="grayscale" + example=true + >}} + +@example {{< img + src="zion-national-park.jpg" + alt="Zion National Park" + filter="grayscale" + example=true + exampleWidth=400 + >}} + +@example {{< img + src="images/examples/zion-national-park.jpg" + alt="Zion National Park" + filter="Text" + filterArgs="Zion National Park,25,250,56" + example=true + >}} + +@example {{< img + src="images/examples/zion-national-park.jpg" + alt="Zion National Park" + filter="Padding" + filterArgs="20,50,20,50,#0705" + example=true + >}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- /* Initialize. */}} +{{- $alt := "" }} +{{- $src := "" }} +{{- $filter := "" }} +{{- $filterArgs := slice }} +{{- $example := false }} +{{- $exampleWidth := 384 }} + +{{- /* Default values to use with the text filter. */}} +{{ $textFilterOpts := dict + "xOffset" 20 + "yOffset" 20 + "fontSize" 64 + "lineHeight" 1.2 + "fontColor" "#ffffff" + "fontPath" "https://github.com/google/fonts/raw/refs/heads/main/ofl/lato/Lato-Regular.ttf" +}} + +{{- /* Get and validate parameters. */}} +{{- with .Get "alt" }} + {{- $alt = . }} +{{- end }} + +{{- with .Get "src" }} + {{- $src = . }} +{{- else }} + {{- errorf "The %q shortcode requires a file parameter. See %s" .Name .Position }} +{{- end }} + +{{- with .Get "filter" }} + {{- $filter = . | lower }} +{{- end }} + +{{- $validFilters := slice + "autoorient" "brightness" "colorbalance" "colorize" "contrast" "dither" + "gamma" "gaussianblur" "grayscale" "hue" "invert" "mask" "none" "opacity" + "overlay" "padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text" + "unsharpmask" +}} + +{{- with $filter }} + {{- if not (in $validFilters .) }} + {{- errorf "The filter passed to the %q shortcode is invalid. The filter must be one of %s. See %s" $.Name (delimit $validFilters ", " ", or ") $.Position }} + {{- end }} +{{- end }} + +{{- with .Get "filterArgs" }} + {{- $filterArgs = split . "," }} + {{- $filterArgs = apply $filterArgs "trim" "." " " }} +{{- end }} + +{{- if in (slice "false" false 0) (.Get "example") }} + {{- $example = false }} +{{- else if in (slice "true" true 1) (.Get "example") }} + {{- $example = true }} +{{- end }} + +{{- with .Get "exampleWidth" }} + {{- $exampleWidth = . | int }} +{{- end }} + +{{- /* Get image. */}} +{{- $ctx := dict "page" .Page "src" $src "name" .Name "position" .Position }} +{{- $i := partial "inline/get-resource.html" $ctx }} + +{{- /* Resize if rendering before/after examples. */}} +{{- if $example }} + {{- $i = $i.Resize (printf "%dx" $exampleWidth) }} +{{- end }} + +{{- /* Create filter. */}} +{{- $f := "" }} +{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }} +{{- if eq $filter "autoorient" }} + {{- $ctx = merge $ctx (dict "argsRequired" 0) }} + {{- template "validate-arg-count" $ctx }} + {{- $f = images.AutoOrient }} +{{- else if eq $filter "brightness" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Brightness (index $filterArgs 0) }} +{{- else if eq $filter "colorbalance" }} + {{- $ctx = merge $ctx (dict "argsRequired" 3) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "percentage red" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "percentage green" "argValue" (index $filterArgs 1) "min" -100 "max" 500) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "percentage blue" "argValue" (index $filterArgs 2) "min" -100 "max" 500) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.ColorBalance (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} +{{- else if eq $filter "colorize" }} + {{- $ctx = merge $ctx (dict "argsRequired" 3) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "hue" "argValue" (index $filterArgs 0) "min" 0 "max" 360) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "saturation" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 2) "min" 0 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Colorize (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} +{{- else if eq $filter "contrast" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Contrast (index $filterArgs 0) }} +{{- else if eq $filter "dither" }} + {{- $f = images.Dither }} +{{- else if eq $filter "gamma" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "gamma" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Gamma (index $filterArgs 0) }} +{{- else if eq $filter "gaussianblur" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.GaussianBlur (index $filterArgs 0) }} +{{- else if eq $filter "grayscale" }} + {{- $ctx = merge $ctx (dict "argsRequired" 0) }} + {{- template "validate-arg-count" $ctx }} + {{- $f = images.Grayscale }} +{{- else if eq $filter "hue" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "shift" "argValue" (index $filterArgs 0) "min" -180 "max" 180) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Hue (index $filterArgs 0) }} +{{- else if eq $filter "invert" }} + {{- $ctx = merge $ctx (dict "argsRequired" 0) }} + {{- template "validate-arg-count" $ctx }} + {{- $f = images.Invert }} +{{- else if eq $filter "mask" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }} + {{- $maskImage := partial "inline/get-resource.html" $ctx }} + {{- $f = images.Mask $maskImage }} +{{- else if eq $filter "opacity" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "opacity" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Opacity (index $filterArgs 0) }} +{{- else if eq $filter "overlay" }} + {{- $ctx = merge $ctx (dict "argsRequired" 3) }} + {{- template "validate-arg-count" $ctx }} + {{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }} + {{- $overlayImg := partial "inline/get-resource.html" $ctx }} + {{- $f = images.Overlay $overlayImg (index $filterArgs 1 | float ) (index $filterArgs 2 | float) }} +{{- else if eq $filter "padding" }} + {{- $ctx = merge $ctx (dict "argsRequired" 5) }} + {{- template "validate-arg-count" $ctx }} + {{- $f = images.Padding + (index $filterArgs 0 | int) + (index $filterArgs 1 | int) + (index $filterArgs 2 | int) + (index $filterArgs 3 | int) + (index $filterArgs 4) + }} +{{- else if eq $filter "pixelate" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "size" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Pixelate (index $filterArgs 0) }} +{{- else if eq $filter "process" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $f = images.Process (index $filterArgs 0) }} +{{- else if eq $filter "saturation" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Saturation (index $filterArgs 0) }} +{{- else if eq $filter "sepia" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Sepia (index $filterArgs 0) }} +{{- else if eq $filter "sigmoid" }} + {{- $ctx = merge $ctx (dict "argsRequired" 2) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "midpoint" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "factor" "argValue" (index $filterArgs 1) "min" -10 "max" 10) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.Sigmoid (index $filterArgs 0) (index $filterArgs 1) }} +{{- else if eq $filter "text" }} + {{- $ctx = merge $ctx (dict "argsRequired" 1) }} + {{- template "validate-arg-count" $ctx }} + {{- $ctx := dict "src" $textFilterOpts.fontPath "name" .Name "position" .Position }} + {{- $font := or (partial "inline/get-resource.html" $ctx) }} + {{- $fontSize := or (index $filterArgs 3 | int) $textFilterOpts.fontSize }} + {{- $lineHeight := math.Max (or (index $filterArgs 4 | float) $textFilterOpts.lineHeight) 1 }} + {{- $opts := dict + "x" (or (index $filterArgs 1 | int) $textFilterOpts.xOffset) + "y" (or (index $filterArgs 2 | int) $textFilterOpts.yOffset) + "size" $fontSize + "linespacing" (mul (sub $lineHeight 1) $fontSize) + "color" (or (index $filterArgs 5) $textFilterOpts.fontColor) + "font" $font + }} + {{- $f = images.Text (index $filterArgs 0) $opts }} +{{- else if eq $filter "unsharpmask" }} + {{- $ctx = merge $ctx (dict "argsRequired" 3) }} + {{- template "validate-arg-count" $ctx }} + {{- $filterArgs = apply $filterArgs "float" "." }} + {{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 500) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "amount" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }} + {{- template "validate-arg-value" $ctx }} + {{- $ctx = merge $ctx (dict "argName" "threshold" "argValue" (index $filterArgs 2) "min" 0 "max" 1) }} + {{- template "validate-arg-value" $ctx }} + {{- $f = images.UnsharpMask (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} +{{- end }} + +{{- /* Apply filter. */}} +{{- $fi := $i }} +{{- with $f }} + {{- $fi = $i.Filter . }} +{{- end }} + +{{- /* Render. */}} +{{- $class := "border-1 border-gray-300 dark:border-gray-500" }} +{{- if $example }} +

    Original

    + {{ $alt }} +

    Processed

    + {{ $alt }} +{{- else -}} + {{ $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 -}} diff --git a/layouts/_shortcodes/imgproc.html b/layouts/_shortcodes/imgproc.html new file mode 100644 index 000000000..fee48525a --- /dev/null +++ b/layouts/_shortcodes/imgproc.html @@ -0,0 +1,39 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders the given image using the given process specification. + +@param {string} path The path to the image, either a page resource or a global resource. +@param {string} spec The image processing specification. +@param {string} alt The alt attribute of the img element. + +@example {{< imgproc path="sunset.jpg" spec="resize 300x" alt="A sunset" >}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- with $.Get "path" }} + {{- with $i := or ($.Page.Resources.Get .) (resources.Get .) }} + {{- with $spec := $.Get "spec" }} + {{- with $i.Process . }} +
    + {{ $.Get `alt` }} +
    + {{- with $.Inner }} + {{ . }} + {{- else }} + {{ $spec }} + {{- end }} +
    +
    + {{- end }} + {{- else }} + {{- errorf "The %q shortcode requires a 'spec' argument containing the image processing specification. See %s" $.Name $.Position }} + {{- end }} + {{- else }} + {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }} + {{- end }} +{{- else }} + {{- errorf "The %q shortcode requires a 'path' argument indicating the image path. The image must be a page resource or a global resource. See %s" $.Name $.Position }} +{{- end }} diff --git a/layouts/_shortcodes/include.html b/layouts/_shortcodes/include.html new file mode 100644 index 000000000..81b0c1d8f --- /dev/null +++ b/layouts/_shortcodes/include.html @@ -0,0 +1,20 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders the page using the RenderShortcode method on the Page object. + +You must call this shortcode using the {{% %}} notation. + +@param {string} (positional parameter 0) The path to the page, relative to the content directory. + +@example {{% include "functions/_common/glob-patterns" %}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- with .Get 0 }} + {{- with or ($.Page.GetPage .) (site.GetPage .) }} + {{- .RenderShortcodes }} + {{- else }} + {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }} + {{- end }} +{{- else }} + {{- errorf "The %q shortcode requires a positional parameter indicating the path of the file to include. See %s" .Name .Position }} +{{- end }} diff --git a/layouts/_shortcodes/list-pages-in-section.html b/layouts/_shortcodes/list-pages-in-section.html new file mode 100644 index 000000000..f6dfe7275 --- /dev/null +++ b/layouts/_shortcodes/list-pages-in-section.html @@ -0,0 +1,69 @@ +{{- /* +Renders a description list of the pages in the given section. + +Render a subset of the pages in the section by specifying a predefined filter, +and whether to include those pages. + +Filters are defined in the data directory, in the file named page_filters. Each +filter is an array of paths to a file, relative to the root of the content +directory. Hugo will throw an error if the specified filter does not exist, or +if any of the pages in the filter do not exist. + +@param {string} path The path to the section. +@param {string} [filter=""] The name of filter list. +@param {string} [filterType=""] The type of filter, either include or exclude. +@param {string} [titlePrefix=""] The string to prepend to the link title. + +@example {{< list-pages-in-section path=/methods/resources >}} +@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude >}} +@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo >}} +*/}} + +{{/* Initialize. */}} +{{ $filter := or "" (.Get "filter" | lower) }} +{{ $filterType := or (.Get "filterType") "none" | lower }} +{{ $filteredPages := slice }} +{{ $titlePrefix := or (.Get "titlePrefix") "" }} + +{{/* Build slice of filtered pages. */}} +{{ with $filter }} + {{ with index site.Data.page_filters . }} + {{ range . }} + {{ with site.GetPage . }} + {{ $filteredPages = $filteredPages | append . }} + {{ else }} + {{ errorf "The %q shortcode was unable to find %q as specified in the page_filters data file. See %s" $.Name . $.Position }} + {{ end }} + {{ end }} + {{ else }} + {{ errorf "The %q shortcode was unable to find the %q filter in the page_filters data file. See %s" $.Name . $.Position }} + {{ end }} +{{ end }} + +{{/* Render. */}} +{{ with $sectionPath := .Get "path" }} + {{ with site.GetPage . }} + {{ with .RegularPages }} + {{ range $page := .ByTitle }} + {{ if or + (and (eq $filterType "include") (in $filteredPages $page)) + (and (eq $filterType "exclude") (not (in $filteredPages $page))) + (eq $filterType "none") + }} + {{ $linkTitle := .LinkTitle }} + {{ with $titlePrefix }} + {{ $linkTitle = printf "%s%s" . $linkTitle }} + {{ end }} +[{{ $linkTitle }}]({{ $page.RelPermalink }}){{/* Do not indent. */}} +: {{ $page.Description }}{{/* Do not indent. */}} + {{ end }} + {{ end }} + {{ else }} + {{ warnf "The %q shortcode found no pages in the %q section. See %s" $.Name $sectionPath $.Position }} + {{ end }} + {{ else }} + {{ errorf "The %q shortcode was unable to find %q. See %s" $.Name $sectionPath $.Position }} + {{ end }} +{{ else }} + {{ errorf "The %q shortcode requires a 'path' parameter indicating the path to the section. See %s" $.Name $.Position }} +{{ end }} diff --git a/layouts/_shortcodes/module-mounts-note.html b/layouts/_shortcodes/module-mounts-note.html new file mode 100644 index 000000000..ba89abcbf --- /dev/null +++ b/layouts/_shortcodes/module-mounts-note.html @@ -0,0 +1,2 @@ +For a more flexible approach to configuring this directory, consult the section +on [module mounts](/configuration/module/#mounts). diff --git a/layouts/_shortcodes/new-in.html b/layouts/_shortcodes/new-in.html new file mode 100644 index 000000000..955d0a710 --- /dev/null +++ b/layouts/_shortcodes/new-in.html @@ -0,0 +1,64 @@ +{{/* prettier-ignore-start */ -}} +{{- /* +Renders a callout or badge indicating the version in which a feature was added. + +To render a callout, include descriptive text between the opening and closing +tags. To render a badge,omit the descriptive text and call the shortcode with a +self-closing tag. + +When comparing the current version to the specified version, the "new in" +button will be hidden if any of the following conditions is true: + +- The major version difference exceeds the majorVersionDiffThreshold +- The minor version difference exceeds the minorVersionDiffThreshold + +@param {string} 0 The semantic version string, with or without a leading v. + +@example {{< new-in 0.100.0 />}} + +@example {{{< new-in 0.100.0 >}} + Some descriptive text here. + {{< /new-in >}} +*/ -}} +{{/* prettier-ignore-end */ -}} +{{- $majorVersionDiffThreshold := 0 }} +{{- $minorVersionDiffThreshold := 30 }} +{{- $displayExpirationWarning := true }} + +{{- with $version := .Get 0 | strings.TrimLeft "vV" }} + {{- $majorVersionDiff := sub (index (split hugo.Version ".") 0 | int) (index (split $version ".") 0 | int) }} + {{- $minorVersionDiff := sub (index (split hugo.Version ".") 1 | int) (index (split $version ".") 1 | int) }} + {{- if or (gt $majorVersionDiff $majorVersionDiffThreshold) (gt $minorVersionDiff $minorVersionDiffThreshold) }} + {{- if $displayExpirationWarning }} + {{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }} + {{- end }} + {{- else }} + {{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }} + {{- with $.Inner }} + {{- $inner := strings.TrimSpace . }} + {{- $text := printf "New in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }} + {{ partial "layouts/blocks/alert.html" (dict + "color" "green" + "icon" "exclamation" + "text" $text + ) + }} + {{- else }} + + + + + + New in + v{{ $version }} + + + {{- end }} + {{- end }} +{{- else }} + {{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }} +{{- end }} diff --git a/layouts/_shortcodes/per-lang-config-keys.html b/layouts/_shortcodes/per-lang-config-keys.html new file mode 100644 index 000000000..31d7daf6a --- /dev/null +++ b/layouts/_shortcodes/per-lang-config-keys.html @@ -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.) }} + + +
    + {{- 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 }} + {{ $k }} + {{ end }} + {{- end }} +
    diff --git a/layouts/_shortcodes/quick-reference.html b/layouts/_shortcodes/quick-reference.html new file mode 100644 index 000000000..0ac544036 --- /dev/null +++ b/layouts/_shortcodes/quick-reference.html @@ -0,0 +1,30 @@ +{{- /* +Renders the child sections of the given top-level section, listing each child's +immediate descendants. + +@param {string} section The top-level section to render. + +@example {{% quick-reference section="/functions" %}} +*/ -}} +{{ $section := "" }} +{{ with .Get "section" }} + {{ $section = . }} +{{ else }} + {{ errorf "The %q shortcode requires a 'section' parameter. See %s" .Name .Position }} +{{ end }} + +{{ with site.GetPage $section }} + {{ range .Sections }} +## {{ .LinkTitle }}{{/* Do not indent. */}} +{{ .Description }}{{/* Do not indent. */}} + {{ .Content }} + {{ with .Pages }} + {{ range . }} +[{{ .LinkTitle }}]({{ .RelPermalink }}){{/* Do not indent. */}} +: {{ .Description }}{{/* Do not indent. */}} + {{ end }} + {{ end }} + {{ end }} +{{ else }} + {{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }} +{{ end }} diff --git a/layouts/_shortcodes/root-configuration-keys.html b/layouts/_shortcodes/root-configuration-keys.html new file mode 100644 index 000000000..46a6e074f --- /dev/null +++ b/layouts/_shortcodes/root-configuration-keys.html @@ -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 "%s" .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 -}} diff --git a/layouts/_shortcodes/syntax-highlighting-styles.html b/layouts/_shortcodes/syntax-highlighting-styles.html new file mode 100644 index 000000000..297849cef --- /dev/null +++ b/layouts/_shortcodes/syntax-highlighting-styles.html @@ -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" ` +Example +`}} +{{- $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") +`}} +{{- $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 }} diff --git a/layouts/baseof.html b/layouts/baseof.html new file mode 100644 index 000000000..4c14a6b6d --- /dev/null +++ b/layouts/baseof.html @@ -0,0 +1,74 @@ + + + + + + {{ .Title }} + + + + {{ partial "layouts/head/head-js.html" . }} + {{ with (templates.Defer (dict "key" "global")) }} + {{ $t := debug.Timer "tailwindcss" }} + {{ with resources.Get "css/styles.css" }} + {{ $opts := dict + "inlineImports" true + "minify" (not hugo.IsDevelopment) + }} + {{ with . | css.TailwindCSS $opts }} + {{ partial "helpers/linkcss.html" (dict "r" .) }} + {{ end }} + {{ end }} + {{ $t.Stop }} + {{ end }} + {{ $noop := .WordCount }} + {{ if .Page.Store.Get "hasMath" }} + + {{ end }} + {{ partial "layouts/head/head.html" . }} + + + {{ partial "layouts/hooks/body-start.html" . }} + {{/* Layout. */}} + {{ block "header" . }} + {{ partial "layouts/header/header.html" . }} + {{ end }} + {{ block "subheader" . }} + {{ end }} + {{ block "hero" . }} + {{ end }} +
    +
    + {{ partial "layouts/hooks/body-main-start.html" . }} + {{ block "main" . }}{{ end }} +
    + {{ block "rightsidebar" . }} + + {{ end }} +
    + {{/* Common icons. */}} + {{ partial "layouts/icons.html" . }} + {{/* Common templates. */}} + {{ partial "layouts/templates.html" . }} + {{/* Footer. */}} + {{ block "footer" . }} + {{ partial "layouts/footer.html" . }} + {{ end }} + {{ partial "layouts/hooks/body-end.html" . }} + + diff --git a/layouts/home.headers b/layouts/home.headers new file mode 100644 index 000000000..1216e42d4 --- /dev/null +++ b/layouts/home.headers @@ -0,0 +1,5 @@ +/* + X-Frame-Options: DENY + X-XSS-Protection: 1; mode=block + X-Content-Type-Options: nosniff + Referrer-Policy: origin-when-cross-origin diff --git a/layouts/home.html b/layouts/home.html new file mode 100644 index 000000000..392f66cd8 --- /dev/null +++ b/layouts/home.html @@ -0,0 +1,52 @@ +{{ define "main" }} +
    + {{ partial "layouts/home/opensource.html" . }} +
    + {{ partial "layouts/home/sponsors.html" (dict "ctx" . "gtag" "home" ) }} +
    + {{ partial "layouts/home/features.html" . }} +
    +{{ end }} + +{{ define "hero" }} +
    +
    +
    + Hugo Logo +

    + The world’s fastest framework for building websites +

    +
    + Hugo is one of the most popular open-source static site generators. + With its amazing speed and flexibility, Hugo makes building websites + fun again. +
    +
    + {{ with site.GetPage "/getting-started" }} + {{ .LinkTitle }} + {{ end }} +
    + {{ partial "layouts/search/button.html" (dict "page" . "standalone" true) }} +
    +
    +
    +
    +
    +{{ end }} + +{{ define "rightsidebar" }} + {{ printf "%c" '\u00A0' }} +{{ end }} + +{{ define "leftsidebar" }} + {{ printf "%c" '\u00A0' }} +{{ end }} diff --git a/layouts/home.redir b/layouts/home.redir new file mode 100644 index 000000000..bb72f96e5 --- /dev/null +++ b/layouts/home.redir @@ -0,0 +1,6 @@ +# Netlify redirects. See https://www.netlify.com/docs/redirects/ +{{ range $p := .Site.Pages -}} +{{ range .Aliases }} +{{ . | printf "%-35s" }} {{ $p.RelPermalink -}} +{{ end -}} +{{- end -}} diff --git a/layouts/index.headers b/layouts/index.headers deleted file mode 100644 index 1216e42d4..000000000 --- a/layouts/index.headers +++ /dev/null @@ -1,5 +0,0 @@ -/* - X-Frame-Options: DENY - X-XSS-Protection: 1; mode=block - X-Content-Type-Options: nosniff - Referrer-Policy: origin-when-cross-origin diff --git a/layouts/index.html b/layouts/index.html deleted file mode 100644 index 392f66cd8..000000000 --- a/layouts/index.html +++ /dev/null @@ -1,52 +0,0 @@ -{{ define "main" }} -
    - {{ partial "layouts/home/opensource.html" . }} -
    - {{ partial "layouts/home/sponsors.html" (dict "ctx" . "gtag" "home" ) }} -
    - {{ partial "layouts/home/features.html" . }} -
    -{{ end }} - -{{ define "hero" }} -
    -
    -
    - Hugo Logo -

    - The world’s fastest framework for building websites -

    -
    - Hugo is one of the most popular open-source static site generators. - With its amazing speed and flexibility, Hugo makes building websites - fun again. -
    -
    - {{ with site.GetPage "/getting-started" }} - {{ .LinkTitle }} - {{ end }} -
    - {{ partial "layouts/search/button.html" (dict "page" . "standalone" true) }} -
    -
    -
    -
    -
    -{{ end }} - -{{ define "rightsidebar" }} - {{ printf "%c" '\u00A0' }} -{{ end }} - -{{ define "leftsidebar" }} - {{ printf "%c" '\u00A0' }} -{{ end }} diff --git a/layouts/index.redir b/layouts/index.redir deleted file mode 100644 index bb72f96e5..000000000 --- a/layouts/index.redir +++ /dev/null @@ -1,6 +0,0 @@ -# Netlify redirects. See https://www.netlify.com/docs/redirects/ -{{ range $p := .Site.Pages -}} -{{ range .Aliases }} -{{ . | printf "%-35s" }} {{ $p.RelPermalink -}} -{{ end -}} -{{- end -}} diff --git a/layouts/list.html b/layouts/list.html new file mode 100644 index 000000000..b049b6da9 --- /dev/null +++ b/layouts/list.html @@ -0,0 +1,69 @@ +{{ define "main" }} + {{ $pages := "" }} + {{ if .IsPage }} + {{/* We currently have a slightly odd content structure with no top level /docs section. */}} + {{ $pages = .CurrentSection.Pages }} + {{ else }} + {{ $pages = .Pages }} + {{ if eq .Section "news" }} + {{ $pages = $pages.ByPublishDate.Reverse }} + {{ end }} + {{ end }} + + +
    + {{ partial "layouts/docsheader.html" . }} + +
    +{{ end }} + +{{ define "rightsidebar" }} + {{ printf "%c" '\u00A0' }} +{{ end }} diff --git a/layouts/list.rss.xml b/layouts/list.rss.xml new file mode 100644 index 000000000..90fa22148 --- /dev/null +++ b/layouts/list.rss.xml @@ -0,0 +1,33 @@ +{{- printf "" | safeHTML }} + + + Hugo News + Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility. + {{ .Permalink }} + Hugo {{ hugo.Version }} + {{ or site.Language.LanguageCode site.Language.Lang }} + {{- with site.Copyright }} + {{ . }} + {{- end }} + {{- with .OutputFormats.Get "rss" }} + {{ printf "" .Permalink .MediaType | safeHTML }} + {{- end }} + {{- $limit := cond (gt site.Config.Services.RSS.Limit 0) site.Config.Services.RSS.Limit 999 }} + {{- $pages := "" }} + {{- with site.GetPage "/news" }} + {{- $pages = .Pages.ByPublishDate.Reverse | first $limit }} + {{- else }} + {{- errorf "The list.rss.xml layout was unable to find the 'news' page." }} + {{- end }} + {{ (index $pages 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{- range $pages }} + + {{ .Title }} + {{ or .Params.permalink .Permalink }} + {{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ or .Params.permalink .Permalink }} + {{ .Summary | transform.XMLEscape | safeHTML }} + + {{- end }} + + diff --git a/layouts/partials/docs/functions-aliases.html b/layouts/partials/docs/functions-aliases.html deleted file mode 100644 index b3a5a7607..000000000 --- a/layouts/partials/docs/functions-aliases.html +++ /dev/null @@ -1,12 +0,0 @@ -{{- with .Params.functions_and_methods.aliases }} - {{- $label := "Alias" }} - {{- if gt (len .) 1 }} - {{- $label = "Aliases" }} - {{- end }} -

    {{ $label }}

    - {{- range . }} -
    - {{- . -}} -
    - {{- end }} -{{- end -}} diff --git a/layouts/partials/docs/functions-return-type.html b/layouts/partials/docs/functions-return-type.html deleted file mode 100644 index 75c97f8d9..000000000 --- a/layouts/partials/docs/functions-return-type.html +++ /dev/null @@ -1,6 +0,0 @@ -{{- with .Params.functions_and_methods.returnType }} -

    Returns

    -
    - {{- . -}} -
    -{{- end -}} diff --git a/layouts/partials/docs/functions-signatures.html b/layouts/partials/docs/functions-signatures.html deleted file mode 100644 index 6fb61df8e..000000000 --- a/layouts/partials/docs/functions-signatures.html +++ /dev/null @@ -1,12 +0,0 @@ -{{- with .Params.functions_and_methods.signatures }} -

    Syntax

    - {{- range . }} - {{- $signature := . }} - {{- if $.Params.function.returnType }} - {{- $signature = printf "%s ⟼ %s" . $.Params.function.returnType }} - {{- end }} -
    - {{- $signature -}} -
    - {{- end }} -{{- end -}} diff --git a/layouts/partials/helpers/debug/list-item-metadata.html b/layouts/partials/helpers/debug/list-item-metadata.html deleted file mode 100644 index d027484b5..000000000 --- a/layouts/partials/helpers/debug/list-item-metadata.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - -
    weight: - {{ .Weight }} -
    keywords: - {{ delimit (or .Keywords "") ", " }} -
    categories: - {{ delimit (or .Params.categories "") ", " }} -
    diff --git a/layouts/partials/helpers/funcs/color-from-string.html b/layouts/partials/helpers/funcs/color-from-string.html deleted file mode 100644 index cd599530b..000000000 --- a/layouts/partials/helpers/funcs/color-from-string.html +++ /dev/null @@ -1,25 +0,0 @@ -{{ $colors := slice "slate" "green" "cyan" "blue" }} -{{ with .single }} - {{ $colors = slice . }} -{{ end }} - -{{ $shades := slice 300 400 500 }} -{{ if not .dark }} - {{ $shades = slice 700 800 }} -{{ end }} -{{ $hash := (hash.FNV32a .text) }} -{{ $i := mod $hash (len $colors) }} -{{ $j := mod $hash (len $shades) }} -{{ $color := index $colors $i }} -{{ $shade1 := index $shades $j }} -{{ $shade2 := 0 }} -{{ $shade3 := 0 }} -{{ if gt $shade1 500 }} - {{ $shade2 = math.Min (sub $shade1 500) 100 | int }} - {{ $shade3 = sub $shade1 100 }} -{{ else }} - {{ $shade2 = math.Max (add $shade1 500) 700 | int }} - {{ $shade3 = add $shade1 200 }} -{{ end }} -{{ $res := dict "color" $color "shade1" $shade1 "shade2" $shade2 "shade3" $shade3 }} -{{ return $res }} diff --git a/layouts/partials/helpers/funcs/get-github-info.html b/layouts/partials/helpers/funcs/get-github-info.html deleted file mode 100644 index 7e2dc89fa..000000000 --- a/layouts/partials/helpers/funcs/get-github-info.html +++ /dev/null @@ -1,28 +0,0 @@ -{{ $url := "https://api.github.com/repos/gohugoio/hugo" }} -{{ $cacheKey := print $url (now.Format "2006-01-02") }} -{{ $headers := dict }} -{{ with os.Getenv "HUGO_GH_TOKEN" }} - {{ $headers = dict "Authorization" (printf "Bearer %s" .) }} -{{ end }} -{{ $opts := dict "headers" $headers "key" $cacheKey }} -{{ $githubRepoInfo := dict }} -{{ with try (resources.GetRemote $url $opts) }} - {{ with .Err }} - {{ warnf "Failed to get GitHub repo info: %s" . }} - {{ else with (.Value | transform.Unmarshal) }} - {{ $githubRepoInfo = dict - "html_url" .html_url - "stargazers_url" .stargazers_url - "watchers_count" .watchers_count - "stargazers_count" .stargazers_count - "forks_count" .forks_count - "contributors_url" .contributors_url - "releases_url" .releases_url - "forks_count" .forks_count - }} - {{ else }} - {{ errorf "Unable to get remote resource %q" $url }} - {{ end }} -{{ end }} - -{{ return $githubRepoInfo }} diff --git a/layouts/partials/helpers/funcs/get-remote-data.html b/layouts/partials/helpers/funcs/get-remote-data.html deleted file mode 100644 index ed7043421..000000000 --- a/layouts/partials/helpers/funcs/get-remote-data.html +++ /dev/null @@ -1,24 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{/* -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" }} -*/}} -{{/* prettier-ignore-end */ -}} -{{ $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 }} diff --git a/layouts/partials/helpers/gtag.html b/layouts/partials/helpers/gtag.html deleted file mode 100644 index 59bf36ba2..000000000 --- a/layouts/partials/helpers/gtag.html +++ /dev/null @@ -1,27 +0,0 @@ -{{ with site.Config.Services.GoogleAnalytics.ID }} - - -{{ end }} diff --git a/layouts/partials/helpers/linkcss.html b/layouts/partials/helpers/linkcss.html deleted file mode 100644 index 814d2b52f..000000000 --- a/layouts/partials/helpers/linkcss.html +++ /dev/null @@ -1,28 +0,0 @@ -{{ $r := .r }} -{{ $attr := .attributes | default dict }} - -{{ if hugo.IsDevelopment }} - -{{ else }} - {{ with $r | minify | fingerprint }} - - {{ end }} -{{ end }} - -{{ define "render-attributes" }} - {{- range $k, $v := . -}} - {{- if $v -}} - {{- printf ` %s=%q` $k $v | safeHTMLAttr -}} - {{- else -}} - {{- printf ` %s` $k | safeHTMLAttr -}} - {{- end -}} - {{- end -}} -{{ end }} diff --git a/layouts/partials/helpers/linkjs.html b/layouts/partials/helpers/linkjs.html deleted file mode 100644 index 00129ad38..000000000 --- a/layouts/partials/helpers/linkjs.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ $r := .r }} -{{ $attr := .attributes | default dict }} -{{ if hugo.IsDevelopment }} - -{{ else }} - {{ with $r | fingerprint }} - - {{ end }} -{{ end }} diff --git a/layouts/partials/helpers/picture.html b/layouts/partials/helpers/picture.html deleted file mode 100644 index 454dd705e..000000000 --- a/layouts/partials/helpers/picture.html +++ /dev/null @@ -1,25 +0,0 @@ -{{ $image := .image }} -{{ $width := .width | default 1000 }} -{{ $width1x := div $width 2 }} -{{ $imageWebp := $image.Resize (printf "%dx webp" $width) }} -{{ $image1x := $image.Resize (printf "%dx" $width1x) }} -{{ $image1xWebp := $image.Resize (printf "%dx webp" $width1x) }} -{{ $class := .class | default "h-64 tablet:h-96 lg:h-full w-full object-cover lg:absolute" }} - - - - - - - diff --git a/layouts/partials/helpers/validation/validate-keywords.html b/layouts/partials/helpers/validation/validate-keywords.html deleted file mode 100644 index 3447ec4ef..000000000 --- a/layouts/partials/helpers/validation/validate-keywords.html +++ /dev/null @@ -1,22 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -We use the front matter keywords field to determine related content. To ensure -consistency, during site build we validate each keyword against the entries in -data/keywords.yaml. - -As of March 5, 2025, this feature is experimental, pending usability -assessment. We anticipate that the number of additions to data/keywords.yaml -will decrease over time, though the initial implementation will require some -effort. -*/}} -{{/* prettier-ignore-end */ -}} -{{- $t := debug.Timer "validateKeywords" }} -{{- $allowedKeywords := collections.Apply site.Data.keywords "strings.ToLower" "." }} -{{- range $p := site.Pages }} - {{- range .Params.keywords }} - {{- if not (in $allowedKeywords (lower .)) }} - {{- warnf "The word or phrase %q is not in the keywords data file. See %s." . $p.Page.String }} - {{- end }} - {{- end }} -{{- end }} -{{- $t.Stop }} diff --git a/layouts/partials/layouts/blocks/alert.html b/layouts/partials/layouts/blocks/alert.html deleted file mode 100644 index 45f0044d9..000000000 --- a/layouts/partials/layouts/blocks/alert.html +++ /dev/null @@ -1,25 +0,0 @@ -{{- $title := .title | default "" }} -{{- $color := .color | default "yellow" }} -{{- $icon := .icon | default "exclamation-triangle" }} -{{- $text := .text | default "" }} -{{- $class := .class | default "mt-6 mb-8" }} -
    -
    -
    - - - -
    -
    - {{- with $title }} -

    - {{ . }} -

    - {{- end }} -
    - {{ $text }} -
    -
    -
    -
    diff --git a/layouts/partials/layouts/blocks/modal.html b/layouts/partials/layouts/blocks/modal.html deleted file mode 100644 index 7d825c06e..000000000 --- a/layouts/partials/layouts/blocks/modal.html +++ /dev/null @@ -1,30 +0,0 @@ -
    -
    - {{ .modal_button }} -
    - -
    diff --git a/layouts/partials/layouts/breadcrumbs.html b/layouts/partials/layouts/breadcrumbs.html deleted file mode 100644 index 69bcf7bd5..000000000 --- a/layouts/partials/layouts/breadcrumbs.html +++ /dev/null @@ -1,44 +0,0 @@ -{{ $documentation := site.GetPage "/documentation" }} - - - - -{{ define "breadcrumbs-arrow" }} - - - -{{ end }} diff --git a/layouts/partials/layouts/date.html b/layouts/partials/layouts/date.html deleted file mode 100644 index 2ec1450a5..000000000 --- a/layouts/partials/layouts/date.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ $humanDate := time.Format "January 2, 2006" . }} -{{ $machineDate := time.Format "2006-01-02T15:04:05-07:00" . }} - diff --git a/layouts/partials/layouts/docsheader.html b/layouts/partials/layouts/docsheader.html deleted file mode 100644 index 7e8e950f3..000000000 --- a/layouts/partials/layouts/docsheader.html +++ /dev/null @@ -1,9 +0,0 @@ -
    - {{ partial "layouts/breadcrumbs.html" . }} - {{ if and .IsPage (not (eq .Layout "list")) }} -

    - {{ .Title }} -

    - {{ end }} -
    diff --git a/layouts/partials/layouts/explorer.html b/layouts/partials/layouts/explorer.html deleted file mode 100644 index bb6f8e96a..000000000 --- a/layouts/partials/layouts/explorer.html +++ /dev/null @@ -1,47 +0,0 @@ -{{/* This is currently not in use, but kept in case I change my mind. */}} - - -{{ define "docs-explorer-section" }} - {{ $p := .p }} - {{ $level := .level }} - {{ $pleft := $level }} - {{ if gt $level 0 }} - {{ $pleft = add $level 1 }} - {{ end }} - {{ $pl := printf "pl-%d" $pleft }} - {{ $pages := $p.Sections }} - - {{ range $pages }} - {{ $hasChildren := gt (len .Pages) 0 }} - {{ $class := cond (eq $level 0) "text-primary hover:text-primary/70" "text-gray-900 dark:text-gray-400 hover:dark:text-gray-300" }} -
  • - - {{ .LinkTitle }} - - {{ if $hasChildren }} -
      - {{ template "docs-explorer-section" (dict "p" . "level" (add $level 1)) }} -
    - {{ end }} -
  • - {{ end }} - -{{ end }} diff --git a/layouts/partials/layouts/footer.html b/layouts/partials/layouts/footer.html deleted file mode 100644 index 1b17e44e4..000000000 --- a/layouts/partials/layouts/footer.html +++ /dev/null @@ -1,73 +0,0 @@ -
    -
    -
    - {{/* Column 1 */}} -
    -
    - By the - Hugo Authors
    -
    - - Hugo Logo - - -
    - - {{/* Sponsors */}} -
    - {{ partial "layouts/home/sponsors.html" (dict - "ctx" . - "gtag" "footer" - - ) - }} -
    -
    -
    -

    - The Hugo logos are copyright © Steve Francia 2013–{{ now.Year }}. The - Hugo Gopher is based on an original work by Renée French. -

    -
    -
    -
    diff --git a/layouts/partials/layouts/head/head-js.html b/layouts/partials/layouts/head/head-js.html deleted file mode 100644 index d83efcd0f..000000000 --- a/layouts/partials/layouts/head/head-js.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ $githubInfo := partialCached "helpers/funcs/get-github-info.html" . "-" }} -{{ $opts := dict "minify" true }} -{{ with resources.Get "js/head-early.js" | js.Build $opts }} - {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "async" "")) }} -{{ end }} -{{ with resources.Get "js/main.js" | js.Build $opts }} - {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "defer" "")) }} -{{ end }} -{{ with resources.Get "js/turbo.js" | js.Build $opts }} - {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "defer" "")) }} -{{ end }} diff --git a/layouts/partials/layouts/head/head.html b/layouts/partials/layouts/head/head.html deleted file mode 100644 index bb27f6a24..000000000 --- a/layouts/partials/layouts/head/head.html +++ /dev/null @@ -1,49 +0,0 @@ - -{{ hugo.Generator }} - -{{ if hugo.IsProduction }} - -{{ else }} - -{{ end }} - - - {{ with .Title }}{{ . }} |{{ end }} - {{ .Site.Title }} - - - - - - - - - - - -{{ range .AlternativeOutputFormats -}} - -{{ end -}} - - - - - - -{{ partial "opengraph/opengraph.html" . }} -{{- template "_internal/schema.html" . -}} -{{- template "_internal/twitter_cards.html" . -}} - -{{ if hugo.IsProduction }} - {{ partial "helpers/gtag.html" . }} -{{ end }} diff --git a/layouts/partials/layouts/header/githubstars.html b/layouts/partials/layouts/header/githubstars.html deleted file mode 100644 index 75db5682a..000000000 --- a/layouts/partials/layouts/header/githubstars.html +++ /dev/null @@ -1,16 +0,0 @@ -{{ with partialCached "helpers/funcs/get-github-info.html" . "-" }} - - - - - - - - {{ printf "%0.1fk" (div .stargazers_count 1000) }} - - -{{ end }} diff --git a/layouts/partials/layouts/header/header.html b/layouts/partials/layouts/header/header.html deleted file mode 100644 index 0d2e720d7..000000000 --- a/layouts/partials/layouts/header/header.html +++ /dev/null @@ -1,44 +0,0 @@ -
    -
    - {{ with site.Home }} - HUGO - {{ end }} -
    -
    - {{ range .Site.Menus.global }} - {{ .Name }} - {{ end }} - -
    - -
    - {{/* Search. */}} - {{ partial "layouts/search/input.html" . }} -
    -
    - {{/* QR code. */}} - {{ partial "layouts/header/qr.html" . }} - {{/* Theme selector. */}} - {{ partial "layouts/header/theme.html" . }} - - {{/* Social. */}} - -
    -
    diff --git a/layouts/partials/layouts/header/qr.html b/layouts/partials/layouts/header/qr.html deleted file mode 100644 index ccc0ee959..000000000 --- a/layouts/partials/layouts/header/qr.html +++ /dev/null @@ -1,25 +0,0 @@ -{{ $t := debug.Timer "qr" }} -{{ $qr := partial "_inline/qr" (dict - "page" $ - "img_class" "w-10 bg-white view-transition-qr" ) -}} -{{ $qrBig := partial "_inline/qr" (dict "page" $ "img_class" "w-64 p-4") }} -{{ $t.Stop }} - - -{{ define "partials/_inline/qr" }} - {{ $img_class := .img_class | default "w-10" }} - {{ with images.QR $.page.Permalink (dict "targetDir" "images/qr") }} - - QR code linking to {{ $.page.Permalink }} - {{ end }} -{{ end }} diff --git a/layouts/partials/layouts/header/theme.html b/layouts/partials/layouts/header/theme.html deleted file mode 100644 index e0b356d1d..000000000 --- a/layouts/partials/layouts/header/theme.html +++ /dev/null @@ -1,35 +0,0 @@ -
    - -
    diff --git a/layouts/partials/layouts/home/features.html b/layouts/partials/layouts/home/features.html deleted file mode 100644 index 527c98cb1..000000000 --- a/layouts/partials/layouts/home/features.html +++ /dev/null @@ -1,56 +0,0 @@ -{{/* icons source: https://heroicons.com/ */}} -{{ $dataTOML := ` - [[features]] - heading = "Optimized for speed" - copy = "Written in Go, optimized for speed and designed for flexibility. With its advanced templating system and fast asset pipelines, Hugo renders a large site in seconds, often less." - icon = """ - - - """ - [[features]] - heading = "Flexible framework" - copy = "With its multilingual support, and powerful taxonomy system, Hugo is widely used to create documentation sites, landing pages, corporate, government, nonprofit, education, news, event, and project sites." - icon = """ - - - """ - [[features]] - heading = "Fast assets pipeline" - copy = "Image processing (convert, resize, crop, rotate, adjust colors, apply filters, overlay text and images, and extract EXIF data), JavaScript bundling (tree shake, code splitting), Sass processing, great TailwindCSS support." - icon = """ - - - """ - [[features]] - heading = "Embedded web server" - copy = "Use Hugo's embedded web server during development to instantly see changes to content, structure, behavior, and presentation. " - icon = """ - - - """ - ` -}} -{{ $data := $dataTOML | transform.Unmarshal }} -
    -
    -
    - {{ range $data.features }} -
    -
    -
    - {{ .icon | safeHTML }} -
    - {{ .heading }} -
    -
    - {{ .copy }} -
    -
    - {{ end }} - -
    -
    -
    diff --git a/layouts/partials/layouts/home/opensource.html b/layouts/partials/layouts/home/opensource.html deleted file mode 100644 index 153c0f4ff..000000000 --- a/layouts/partials/layouts/home/opensource.html +++ /dev/null @@ -1,111 +0,0 @@ -{{ $githubInfo := partialCached "helpers/funcs/get-github-info.html" . "-" }} -
    -
    -
    -
    -

    - Open source -

    -

    - Hugo is open source and free to use. It is distributed under the - Apache 2.0 License. -

    -
    -
    -
    - - - - Popular. -
    -
    - Hugo has - {{ $githubInfo.stargazers_count | lang.FormatNumber 0 }} - stars on GitHub as of {{ now.Format "January 2, 2006" }}. - Join the crowd and hit the - Star button. -
    -
    -
    -
    - - - - Active. -
    -
    - Hugo has a large and active community. If you have questions or - need help, you can ask in the - Hugo forums. -
    -
    -
    -
    - - - - Frequent releases. -
    -
    - Hugo has a fast - release - cycle. The project is actively maintained and new features are - added regularly. -
    -
    -
    -
    -
    - {{ partial "helpers/picture.html" (dict - "image" (resources.Get "images/hugo-github-screenshot.png") - "alt" "Hugo GitHub Repository" - "width" 640 - "class" "w-full max-w-[38rem] ring-1 shadow-xl dark:shadow-gray-500 ring-gray-400/10") - }} -
    -
    diff --git a/layouts/partials/layouts/home/sponsors.html b/layouts/partials/layouts/home/sponsors.html deleted file mode 100644 index 1f391e1ec..000000000 --- a/layouts/partials/layouts/home/sponsors.html +++ /dev/null @@ -1,44 +0,0 @@ -{{ $gtag := .gtag | default "unknown" }} -{{ $gtag := .gtag | default "unknown" }} -{{ $isFooter := (eq $gtag "footer") }} -{{ $utmSource := cond $isFooter "hugofooter" "hugohome" }} -{{ $containerClass := .containerClass | default "mx-auto max-w-7xl px-6 lg:px-8" }} -{{ with .ctx.Site.Data.sponsors }} -
    -

    Hugo Sponsors

    -
    - {{ range .banners }} -
    - {{ $query_params := .query_params | default "" }} - {{ $url := .link }} - {{ if not .no_query_params }} - {{ $url = printf "%s?%s%s" .link $query_params (querify "utm_source" (.utm_source | default $utmSource ) "utm_medium" (.utm_medium | default "banner") "utm_campaign" (.utm_campaign | default "hugosponsor") "utm_content" (.utm_content | default "gohugoio")) | safeURL }} - {{ end }} - {{ $logo := resources.Get .logo }} - {{ $gtagID := printf "Sponsor %s %s" .name $gtag | title }} - - - -
    - {{ end }} -
    -
    -{{ end }} diff --git a/layouts/partials/layouts/hooks/body-end.html b/layouts/partials/layouts/hooks/body-end.html deleted file mode 100644 index 9ffd93ba8..000000000 --- a/layouts/partials/layouts/hooks/body-end.html +++ /dev/null @@ -1,3 +0,0 @@ -{{- if .IsHome }} - {{- partial "helpers/validation/validate-keywords.html" }} -{{- end }} diff --git a/layouts/partials/layouts/hooks/body-main-start.html b/layouts/partials/layouts/hooks/body-main-start.html deleted file mode 100644 index b28dd21c8..000000000 --- a/layouts/partials/layouts/hooks/body-main-start.html +++ /dev/null @@ -1,8 +0,0 @@ -{{ if or .IsSection .IsPage }} - -{{end }} diff --git a/layouts/partials/layouts/hooks/body-start.html b/layouts/partials/layouts/hooks/body-start.html deleted file mode 100644 index 3430bd846..000000000 --- a/layouts/partials/layouts/hooks/body-start.html +++ /dev/null @@ -1,3 +0,0 @@ -{{ with resources.Get "js/body-start.js" | js.Build (dict "minify" true) }} - {{ partial "helpers/linkjs.html" (dict "r" . "attributes" (dict "" "")) }} -{{ end }} diff --git a/layouts/partials/layouts/icons.html b/layouts/partials/layouts/icons.html deleted file mode 100644 index b05adef00..000000000 --- a/layouts/partials/layouts/icons.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{{/* https://heroicons.com/mini exclamation-circle */}} - - - - -{{/* https://heroicons.com/mini exclamation-triangle */}} - - - - -{{/* https://heroicons.com/mini information-circle */}} - - - - -{{/* https://heroicons.com/mini light-bulb */}} - - - diff --git a/layouts/partials/layouts/in-this-section.html b/layouts/partials/layouts/in-this-section.html deleted file mode 100644 index 28e5ed7eb..000000000 --- a/layouts/partials/layouts/in-this-section.html +++ /dev/null @@ -1,34 +0,0 @@ -{{- with .CurrentSection.RegularPages }} - {{ $hasTocOrRelated := or ($.Store.Get "hasToc") ($.Store.Get "hasRelated") }} -
    -

    - In this section -

    - - -
    -{{- end }} diff --git a/layouts/partials/layouts/page-edit.html b/layouts/partials/layouts/page-edit.html deleted file mode 100644 index 6a976d11a..000000000 --- a/layouts/partials/layouts/page-edit.html +++ /dev/null @@ -1,26 +0,0 @@ -
    -
    - -
    - Last updated: - {{ .Lastmod.Format "January 2, 2006" }}{{ with .GitInfo }} - : - {{ .Subject }} ({{ .AbbreviatedHash }}) - {{ end }} -
    - - {{ with .File }} - {{ if not .IsContentAdapter }} - {{ $href := printf "%sedit/master/content/%s/%s" site.Params.ghrepo $.Lang .Path }} - - Improve this page - - {{ end }} - {{ end }} -
    diff --git a/layouts/partials/layouts/related.html b/layouts/partials/layouts/related.html deleted file mode 100644 index 0245ba771..000000000 --- a/layouts/partials/layouts/related.html +++ /dev/null @@ -1,22 +0,0 @@ -{{- $heading := "See also" }} -{{- $related := site.Pages.Related . }} -{{- $related = $related | complement .CurrentSection.Pages | first 7 }} - -{{- with $related }} - {{ $.Store.Set "hasRelated" true }} -

    - {{ $heading }} -

    - -{{- end }} diff --git a/layouts/partials/layouts/search/algolialogo.html b/layouts/partials/layouts/search/algolialogo.html deleted file mode 100644 index a7fc6c0ae..000000000 --- a/layouts/partials/layouts/search/algolialogo.html +++ /dev/null @@ -1,45 +0,0 @@ -
    - Search by - - - - - - - - - - -
    diff --git a/layouts/partials/layouts/search/button.html b/layouts/partials/layouts/search/button.html deleted file mode 100644 index 07c1f7335..000000000 --- a/layouts/partials/layouts/search/button.html +++ /dev/null @@ -1,22 +0,0 @@ -{{ $textColor := "text-gray-300" }} -{{ $fillColor := "fill-slate-400 dark:fill-slate-500" }} -{{ if .standalone }} - {{ $textColor = "text-gray-800 dark:text-gray-300 " }} - {{ $fillColor = "fill-slate-500 dark:fill-slate-400" }} -{{ end }} - - - diff --git a/layouts/partials/layouts/search/input.html b/layouts/partials/layouts/search/input.html deleted file mode 100644 index 5f5ff07b9..000000000 --- a/layouts/partials/layouts/search/input.html +++ /dev/null @@ -1,4 +0,0 @@ -
    - {{ partial "layouts/search/button.html" (dict "page" . "standalone" false) }} - {{ partial "layouts/search/results.html" . }} -
    diff --git a/layouts/partials/layouts/search/results.html b/layouts/partials/layouts/search/results.html deleted file mode 100644 index cd9b88dc0..000000000 --- a/layouts/partials/layouts/search/results.html +++ /dev/null @@ -1,90 +0,0 @@ - diff --git a/layouts/partials/layouts/templates.html b/layouts/partials/layouts/templates.html deleted file mode 100644 index 72b71a3d9..000000000 --- a/layouts/partials/layouts/templates.html +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/layouts/partials/layouts/toc.html b/layouts/partials/layouts/toc.html deleted file mode 100644 index 774bc15c7..000000000 --- a/layouts/partials/layouts/toc.html +++ /dev/null @@ -1,46 +0,0 @@ -{{ with .Fragments }} - {{ with .Headings }} -
    -

    - On this page -

    - -
    - {{ end }} -{{ end }} - -{{ define "render-toc-level" }} - {{ range .h }} - {{ if and .ID (and (ge .Level 2) (le .Level 4)) }} - {{ $indentation := "ml-0" }} - {{ if eq .Level 3 }} - {{ $indentation = "ml-2 lg:ml-3" }} - {{ else if eq .Level 4 }} - {{ $indentation = "ml-4 lg:ml-6" }} - {{ end }} - {{ $.p.Store.Set "hasToc" true }} -
  • - - {{ .Title | safeHTML }} - -
  • - {{ end }} - {{ with .Headings }} - - {{ end }} - {{ end }} -{{ end }} diff --git a/layouts/partials/opengraph/get-featured-image.html b/layouts/partials/opengraph/get-featured-image.html deleted file mode 100644 index 50ee2a44d..000000000 --- a/layouts/partials/opengraph/get-featured-image.html +++ /dev/null @@ -1,26 +0,0 @@ -{{ $images := $.Resources.ByType "image" }} -{{ $featured := $images.GetMatch "*feature*" }} -{{ if not $featured }} - {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} -{{ end }} -{{ if not $featured }} - {{ $featured = resources.Get "/opengraph/gohugoio-card-base-1.png" }} - {{ $size := 80 }} - {{ $title := $.LinkTitle }} - {{ if gt (len $title) 20 }} - {{ $size = 70 }} - {{ end }} - - {{ $text := $title }} - {{ $textOptions := dict - "color" "#FFF" - "size" $size - "lineSpacing" 10 - "x" 65 "y" 80 - "font" (resources.Get "/opengraph/mulish-black.ttf") - }} - - {{ $featured = $featured | images.Filter (images.Text $text $textOptions) }} -{{ end }} - -{{ return $featured }} diff --git a/layouts/partials/opengraph/opengraph.html b/layouts/partials/opengraph/opengraph.html deleted file mode 100644 index e32e07298..000000000 --- a/layouts/partials/opengraph/opengraph.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - - -{{- with $.Params.images -}} - {{- range first 6 . }} - - {{ end -}} -{{- else -}} - {{- $featured := partial "opengraph/get-featured-image.html" . }} - {{- with $featured -}} - - {{- else -}} - {{- with $.Site.Params.images }} - - {{ end -}} - {{- end -}} -{{- end -}} - -{{- if .IsPage }} - {{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} - - {{ with .PublishDate }} - - {{ end }} - {{ with .Lastmod }} - - {{ end }} -{{- end -}} - -{{- with .Params.audio }}{{ end }} -{{- with .Params.locale }} - -{{ end }} -{{- with .Site.Params.title }} - -{{ end }} -{{- with .Params.videos }} - {{- range . }} - - {{ end }} - -{{ end }} - -{{- /* If it is part of a series, link to related articles */}} -{{- $permalink := .Permalink }} -{{- $siteSeries := .Site.Taxonomies.series }} -{{ with .Params.series }} - {{- range $name := . }} - {{- $series := index $siteSeries ($name | urlize) }} - {{- range $page := first 6 $series.Pages }} - {{- if ne $page.Permalink $permalink }} - - {{ end }} - {{- end }} - {{ end }} - -{{ end }} - -{{- /* Facebook Page Admin ID for Domain Insights */}} -{{- with site.Params.social.facebook_admin }} - -{{ end }} diff --git a/layouts/shortcodes/chroma-lexers.html b/layouts/shortcodes/chroma-lexers.html deleted file mode 100644 index fd7130501..000000000 --- a/layouts/shortcodes/chroma-lexers.html +++ /dev/null @@ -1,28 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders an HTML template of Chroma lexers and their aliases. - -@example {{< chroma-lexers >}} -*/ -}} -{{/* prettier-ignore-end */ -}} -
    - - - - - - - {{- range site.Data.docs.chroma.lexers }} - - - - - {{- end }} - -
    LanguageIdentifiers
    {{ .Name }} - {{- range $k, $_ := .Aliases }} - {{- if $k }},{{ end }} - {{ . }} - {{- end }} -
    -
    diff --git a/layouts/shortcodes/code-toggle.html b/layouts/shortcodes/code-toggle.html deleted file mode 100644 index a22c378be..000000000 --- a/layouts/shortcodes/code-toggle.html +++ /dev/null @@ -1,120 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats. - -@param {string} [config] The section of site.Data.docs.config to render. -@param {bool} [copy=false] Whether to display a copy-to-clipboard button. -@param {string} [dataKey] The section of site.Data.docs to render. -@param {string} [file] The file name to display above the rendered code. -@param {bool} [fm=false] Whether to render the code as front matter. -@param {bool} [skipHeader=false] Whether to omit top level key(s) when rendering a section of site.Data.docs.config. - -@example {{< code-toggle file=hugo config=build />}} - -@example {{< code-toggle file=content/example.md fm="true" }} - title='Example' - draft='false - {{< /code-toggle }} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- /* Initialize. */}} -{{- $config := "" }} -{{- $copy := false }} -{{- $dataKey := "" }} -{{- $file := "" }} -{{- $fm := false }} -{{- $skipHeader := false }} - -{{- /* Get parameters. */}} -{{- $config = .Get "config" }} -{{- $dataKey = .Get "dataKey" }} -{{- $file = .Get "file" }} -{{- if in (slice "false" false 0) (.Get "copy") }} - {{- $copy = false }} -{{- else if in (slice "true" true 1) (.Get "copy") }} - {{- $copy = true }} -{{- end }} -{{- if in (slice "false" false 0) (.Get "fm") }} - {{- $fm = false }} -{{- else if in (slice "true" true 1) (.Get "fm") }} - {{- $fm = true }} -{{- end }} -{{- if in (slice "false" false 0) (.Get "skipHeader") }} - {{- $skipHeader = false }} -{{- else if in (slice "true" true 1) (.Get "skipHeader") }} - {{- $skipHeader = true }} -{{- end }} - -{{- /* Define constants. */}} -{{- $delimiters := dict "toml" "+++" "yaml" "---" }} -{{- $langs := slice "yaml" "toml" "json" }} -{{- $placeHolder := "#-hugo-placeholder-#" }} - -{{- /* Render. */}} -{{- $code := "" }} -{{- if $config }} - {{- $file = $file | default "hugo" }} - {{- $sections := (split $config ".") }} - {{- $configSection := index $.Site.Data.docs.config $sections }} - {{- $code = dict $sections $configSection }} - {{- if $skipHeader }} - {{- $code = $configSection }} - {{- end }} -{{- else if $dataKey }} - {{- $file = $file | default $dataKey }} - {{- $sections := (split $dataKey ".") }} - {{- $code = index $.Site.Data.docs $sections }} -{{- else }} - {{- $code = $.Inner }} -{{- end }} - - -
    - {{- if $copy }} - - - - {{- end }} - - {{- if $code }} - {{- range $i, $lang := $langs }} -
    - {{- $hCode := $code | transform.Remarshal . }} - {{- if and $fm (in (slice "toml" "yaml") .) }} - {{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }} - {{- end }} - {{- $hCode = $hCode | replaceRE `\n+` "\n" }} - {{- highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }} -
    - {{- end }} - {{- end }} -
    diff --git a/layouts/shortcodes/datatable-filtered.html b/layouts/shortcodes/datatable-filtered.html deleted file mode 100644 index de8b0cf55..000000000 --- a/layouts/shortcodes/datatable-filtered.html +++ /dev/null @@ -1,47 +0,0 @@ -{{ $package := (index .Params 0) }} -{{ $listname := (index .Params 1) }} -{{ $filter := split (index .Params 2) " " }} -{{ $filter1 := index $filter 0 }} -{{ $filter2 := index $filter 1 }} -{{ $filter3 := index $filter 2 }} - -{{ $list := (index (index .Site.Data.docs $package) $listname) }} -{{ $fields := after 3 .Params }} -{{ $list := where $list $filter1 $filter2 $filter3 }} - - -
    - - - - {{ range $fields }} - - {{ end }} - - - - {{ range $list }} - - {{ range $k, $v := . }} - {{ $.Scratch.Set $k $v }} - {{ end }} - {{ range $k, $v := $fields }} - - {{ end }} - - {{ end }} - -
    {{ . }}
    - {{ $tdContent := $.Scratch.Get . }} - {{ if eq $k 3 }} - {{ printf "%v" $tdContent | - strings.ReplaceRE `\[` "
    1. " | - strings.ReplaceRE `\s` "
    2. " | - strings.ReplaceRE `\]` "
    " | - safeHTML - }} - {{ else }} - {{ $tdContent }} - {{ end }} -
    -
    diff --git a/layouts/shortcodes/datatable.html b/layouts/shortcodes/datatable.html deleted file mode 100644 index f135d841c..000000000 --- a/layouts/shortcodes/datatable.html +++ /dev/null @@ -1,39 +0,0 @@ -{{ $package := (index .Params 0) }} -{{ $listname := (index .Params 1) }} -{{ $list := (index (index .Site.Data.docs $package) $listname) }} -{{ $fields := after 2 .Params }} - - -
    - - - - {{ range $fields }} - {{ $s := . }} - {{ if eq $s "_key" }} - {{ $s = "type" }} - {{ end }} - - {{ end }} - - - - {{ range $k1, $v1 := $list }} - - {{ range $k2, $v2 := . }} - {{ $.Scratch.Set $k2 $v2 }} - {{ end }} - {{ range $fields }} - {{ $s := "" }} - {{ if eq . "_key" }} - {{ $s = $k1 }} - {{ else }} - {{ $s = $.Scratch.Get . }} - {{ end }} - - {{ end }} - - {{ end }} - -
    {{ $s }}
    {{ $s }}
    -
    diff --git a/layouts/shortcodes/deprecated-in.html b/layouts/shortcodes/deprecated-in.html deleted file mode 100644 index ce2ba389e..000000000 --- a/layouts/shortcodes/deprecated-in.html +++ /dev/null @@ -1,29 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders a callout indicating the version in which a feature was deprecated. - -Include descriptive text between the opening and closing tags, or omit the -descriptive text and call the shortcode with a self-closing tag. - -@param {string} 0 The semantic version string, with or without a leading v. - -@example {{< deprecated-in 0.144.0 />}} - -@example {{< deprecated-in 0.144.0 >}} - Some descriptive text here. - {{< /deprecated-in >}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- with $version := .Get 0 | strings.TrimLeft "vV" }} - {{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }} - {{- $inner := strings.TrimSpace $.Inner }} - {{- $text := printf "Deprecated in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }} - {{- partial "layouts/blocks/alert.html" (dict - "color" "orange" - "icon" "exclamation" - "text" $text - ) - }} -{{- else }} - {{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }} -{{- end }} diff --git a/layouts/shortcodes/eturl.html b/layouts/shortcodes/eturl.html deleted file mode 100644 index a0237dbe0..000000000 --- a/layouts/shortcodes/eturl.html +++ /dev/null @@ -1,26 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders an absolute URL to the source code for an embedded template. - -Accepts either positional or named parameters, and depends on the -embedded_templates.toml file in the data directory. - -@param {string} filename The embedded template's file name, excluding extension. - -@example {{% et robots.txt %}} -@example {{% et filename=robots.txt %}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- with $filename := or (.Get "filename") (.Get 0) }} - {{- with site.Data.embedded_template_urls }} - {{- with index . $filename }} - {{- urls.JoinPath site.Data.embedded_template_urls.base_url . }} - {{- else }} - {{- errorf "The %q shortcode was unable to find a URL for the embedded template named %q. Check the name. See %s" $.Name $filename $.Position }} - {{- end }} - {{- else }} - {{- errorf "The %q shortcode was unable to find the embedded_template_urls data file in the site's data directory. See %s" $.Name $.Position }} - {{- end }} -{{- else }} - {{- errorf "The %q shortcodes requires a named or positional parameter, the file name of the embedded template, excluding its extension. See %s" .Name .Position }} -{{- end -}} diff --git a/layouts/shortcodes/glossary-term.html b/layouts/shortcodes/glossary-term.html deleted file mode 100644 index 2a45dc8cb..000000000 --- a/layouts/shortcodes/glossary-term.html +++ /dev/null @@ -1,18 +0,0 @@ -{{- /* -Renders the definition of the given glossary term. - -@param {string} (.Get 0) The glossary term. - -@example {{% glossary-term float %}} -@example {{% glossary-term "floating point" %}} -*/ -}} -{{- with .Get 0 }} - {{- $path := printf "/quick-reference/glossary/%s" (urlize .) }} - {{- with site.GetPage $path }} -{{ .RenderShortcodes }}{{/* Do not indent. */}} - {{- else }} - {{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }} - {{- end }} -{{- else }} - {{- errorf "The glossary term (%s) shortcode requires one positional parameter: see %s" $.Name $.Position }} -{{- end -}} diff --git a/layouts/shortcodes/glossary.html b/layouts/shortcodes/glossary.html deleted file mode 100644 index 7331d5c9f..000000000 --- a/layouts/shortcodes/glossary.html +++ /dev/null @@ -1,54 +0,0 @@ -{{- /* -Renders the glossary of terms. - -When you call this shortcode using the {{% %}} notation, the glossary terms are -Markdown headings (level 6) which means they are members of .Fragments. This -allows the link render hook to verify links to glossary terms. - -Yes, the terms themselves are pages, but we don't want to link to the pages, at -least not right now. Instead, we want to link to the ids rendered by this -shortcode. - -@example {{% glossary %}} -*/ -}} -{{- $path := "/quick-reference/glossary" }} -{{- with site.GetPage $path }} - - {{- /* Build and render alphabetical index. */}} - {{- $m := dict }} - {{- range $p := .Pages.ByTitle }} - {{- $k := substr .Title 0 1 | strings.ToUpper }} - {{- if index $m $k }} - {{- continue }} - {{- end }} - {{- $anchor := path.BaseName .Path | anchorize }} - {{- $m = merge $m (dict $k $anchor) }} - {{- end }} - {{- range $k, $v := $m }} -[{{ $k }}](#{{ $v }}) {{/* Do not indent. */}} - {{- end }} - - {{/* Render glossary terms. */}} - {{- range $p := .Pages.ByTitle }} -{{ .Title }}{{/* Do not indent. */}} -: {{ .RawContent | strings.TrimSpace | safeHTML }}{{/* Do not indent. */}} - {{ with .Params.reference }} - {{- $destination := "" }} - {{- with $u := urls.Parse . }} - {{- if $u.IsAbs }} - {{- $destination = $u.String }} - {{- else }} - {{- with site.GetPage $u.Path }} - {{- $destination = .RelPermalink }} - {{- else }} - {{- errorf "The %q shortcode was unable to find the reference link %s: see %s" $.Name . $p.String }} - {{- end }} - {{- end }} - {{- end }} -: See [details]({{ $destination }}).{{/* Do not indent. */}} - {{- end }} - {{ end }} - -{{- else }} - {{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}} -{{- end }} diff --git a/layouts/shortcodes/hl.html b/layouts/shortcodes/hl.html deleted file mode 100644 index 3fafcb5e8..000000000 --- a/layouts/shortcodes/hl.html +++ /dev/null @@ -1,14 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Returns syntax-highlighted code from the given text. - -This is useful as a terse way to highlight inline code snippets. Calling the -highlight shortcode for inline snippets is verbose. - -@example This is {{< hl python >}}inline{{< /hl >}} code. -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- $code := .Inner | strings.TrimSpace }} -{{- $lang := or (.Get 0) "go" }} -{{- $opts := dict "hl_inline" true "noClasses" true }} -{{- transform.Highlight $code $lang $opts }} diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html deleted file mode 100644 index 60187802e..000000000 --- a/layouts/shortcodes/img.html +++ /dev/null @@ -1,391 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders the given image using the given filter, if any. - -When using the text filter, provide the arguments in this order: - -0. The text -1. The horizontal offset, in pixels, relative to the left of the image (default 20) -2. The vertical offset, in pixels, relative to the top of the image (default 20) -3. The font size in pixels (default 64) -4. The line height (default 1.2) -5. The font color (default #ffffff) - -When using the padding filter, provide all arguments in this order: - -0. Padding top -1. Padding right -2. Padding bottom -3. Padding right -4. Canvas color - -@param {string} src The path to the image which must be a remote, page, or global resource. -@param {string} [filter] The filter to apply to the image (case-insensitive). -@param {string} [filterArgs] A comma-delimited list of arguments to pass to the filter. -@param {bool} [example=false] If true, renders a before/after example. -@param {int} [exampleWidth=384] Image width, in pixels, when rendering a before/after example. - -@example {{< img src="zion-national-park.jpg" >}} -@example {{< img src="zion-national-park.jpg" alt="Zion National Park" >}} - -@example {{< img - src="zion-national-park.jpg" - alt="Zion National Park" - filter="grayscale" - >}} - -@example {{< img - src="zion-national-park.jpg" - alt="Zion National Park" - filter="process" - filterArgs="resize 400x webp" - >}} - -@example {{< img - src="zion-national-park.jpg" - alt="Zion National Park" - filter="colorize" - filterArgs="180,50,20" - >}} - -@example {{< img - src="zion-national-park.jpg" - alt="Zion National Park" - filter="grayscale" - example=true - >}} - -@example {{< img - src="zion-national-park.jpg" - alt="Zion National Park" - filter="grayscale" - example=true - exampleWidth=400 - >}} - -@example {{< img - src="images/examples/zion-national-park.jpg" - alt="Zion National Park" - filter="Text" - filterArgs="Zion National Park,25,250,56" - example=true - >}} - -@example {{< img - src="images/examples/zion-national-park.jpg" - alt="Zion National Park" - filter="Padding" - filterArgs="20,50,20,50,#0705" - example=true - >}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- /* Initialize. */}} -{{- $alt := "" }} -{{- $src := "" }} -{{- $filter := "" }} -{{- $filterArgs := slice }} -{{- $example := false }} -{{- $exampleWidth := 384 }} - -{{- /* Default values to use with the text filter. */}} -{{ $textFilterOpts := dict - "xOffset" 20 - "yOffset" 20 - "fontSize" 64 - "lineHeight" 1.2 - "fontColor" "#ffffff" - "fontPath" "https://github.com/google/fonts/raw/refs/heads/main/ofl/lato/Lato-Regular.ttf" -}} - -{{- /* Get and validate parameters. */}} -{{- with .Get "alt" }} - {{- $alt = . }} -{{- end }} - -{{- with .Get "src" }} - {{- $src = . }} -{{- else }} - {{- errorf "The %q shortcode requires a file parameter. See %s" .Name .Position }} -{{- end }} - -{{- with .Get "filter" }} - {{- $filter = . | lower }} -{{- end }} - -{{- $validFilters := slice - "autoorient" "brightness" "colorbalance" "colorize" "contrast" "dither" - "gamma" "gaussianblur" "grayscale" "hue" "invert" "mask" "none" "opacity" - "overlay" "padding" "pixelate" "process" "saturation" "sepia" "sigmoid" "text" - "unsharpmask" -}} - -{{- with $filter }} - {{- if not (in $validFilters .) }} - {{- errorf "The filter passed to the %q shortcode is invalid. The filter must be one of %s. See %s" $.Name (delimit $validFilters ", " ", or ") $.Position }} - {{- end }} -{{- end }} - -{{- with .Get "filterArgs" }} - {{- $filterArgs = split . "," }} - {{- $filterArgs = apply $filterArgs "trim" "." " " }} -{{- end }} - -{{- if in (slice "false" false 0) (.Get "example") }} - {{- $example = false }} -{{- else if in (slice "true" true 1) (.Get "example") }} - {{- $example = true }} -{{- end }} - -{{- with .Get "exampleWidth" }} - {{- $exampleWidth = . | int }} -{{- end }} - -{{- /* Get image. */}} -{{- $ctx := dict "page" .Page "src" $src "name" .Name "position" .Position }} -{{- $i := partial "inline/get-resource.html" $ctx }} - -{{- /* Resize if rendering before/after examples. */}} -{{- if $example }} - {{- $i = $i.Resize (printf "%dx" $exampleWidth) }} -{{- end }} - -{{- /* Create filter. */}} -{{- $f := "" }} -{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }} -{{- if eq $filter "autoorient" }} - {{- $ctx = merge $ctx (dict "argsRequired" 0) }} - {{- template "validate-arg-count" $ctx }} - {{- $f = images.AutoOrient }} -{{- else if eq $filter "brightness" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Brightness (index $filterArgs 0) }} -{{- else if eq $filter "colorbalance" }} - {{- $ctx = merge $ctx (dict "argsRequired" 3) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "percentage red" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "percentage green" "argValue" (index $filterArgs 1) "min" -100 "max" 500) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "percentage blue" "argValue" (index $filterArgs 2) "min" -100 "max" 500) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.ColorBalance (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} -{{- else if eq $filter "colorize" }} - {{- $ctx = merge $ctx (dict "argsRequired" 3) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "hue" "argValue" (index $filterArgs 0) "min" 0 "max" 360) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "saturation" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 2) "min" 0 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Colorize (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} -{{- else if eq $filter "contrast" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Contrast (index $filterArgs 0) }} -{{- else if eq $filter "dither" }} - {{- $f = images.Dither }} -{{- else if eq $filter "gamma" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "gamma" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Gamma (index $filterArgs 0) }} -{{- else if eq $filter "gaussianblur" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.GaussianBlur (index $filterArgs 0) }} -{{- else if eq $filter "grayscale" }} - {{- $ctx = merge $ctx (dict "argsRequired" 0) }} - {{- template "validate-arg-count" $ctx }} - {{- $f = images.Grayscale }} -{{- else if eq $filter "hue" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "shift" "argValue" (index $filterArgs 0) "min" -180 "max" 180) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Hue (index $filterArgs 0) }} -{{- else if eq $filter "invert" }} - {{- $ctx = merge $ctx (dict "argsRequired" 0) }} - {{- template "validate-arg-count" $ctx }} - {{- $f = images.Invert }} -{{- else if eq $filter "mask" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }} - {{- $maskImage := partial "inline/get-resource.html" $ctx }} - {{- $f = images.Mask $maskImage }} -{{- else if eq $filter "opacity" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "opacity" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Opacity (index $filterArgs 0) }} -{{- else if eq $filter "overlay" }} - {{- $ctx = merge $ctx (dict "argsRequired" 3) }} - {{- template "validate-arg-count" $ctx }} - {{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }} - {{- $overlayImg := partial "inline/get-resource.html" $ctx }} - {{- $f = images.Overlay $overlayImg (index $filterArgs 1 | float ) (index $filterArgs 2 | float) }} -{{- else if eq $filter "padding" }} - {{- $ctx = merge $ctx (dict "argsRequired" 5) }} - {{- template "validate-arg-count" $ctx }} - {{- $f = images.Padding - (index $filterArgs 0 | int) - (index $filterArgs 1 | int) - (index $filterArgs 2 | int) - (index $filterArgs 3 | int) - (index $filterArgs 4) - }} -{{- else if eq $filter "pixelate" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "size" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Pixelate (index $filterArgs 0) }} -{{- else if eq $filter "process" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $f = images.Process (index $filterArgs 0) }} -{{- else if eq $filter "saturation" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Saturation (index $filterArgs 0) }} -{{- else if eq $filter "sepia" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Sepia (index $filterArgs 0) }} -{{- else if eq $filter "sigmoid" }} - {{- $ctx = merge $ctx (dict "argsRequired" 2) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "midpoint" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "factor" "argValue" (index $filterArgs 1) "min" -10 "max" 10) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.Sigmoid (index $filterArgs 0) (index $filterArgs 1) }} -{{- else if eq $filter "text" }} - {{- $ctx = merge $ctx (dict "argsRequired" 1) }} - {{- template "validate-arg-count" $ctx }} - {{- $ctx := dict "src" $textFilterOpts.fontPath "name" .Name "position" .Position }} - {{- $font := or (partial "inline/get-resource.html" $ctx) }} - {{- $fontSize := or (index $filterArgs 3 | int) $textFilterOpts.fontSize }} - {{- $lineHeight := math.Max (or (index $filterArgs 4 | float) $textFilterOpts.lineHeight) 1 }} - {{- $opts := dict - "x" (or (index $filterArgs 1 | int) $textFilterOpts.xOffset) - "y" (or (index $filterArgs 2 | int) $textFilterOpts.yOffset) - "size" $fontSize - "linespacing" (mul (sub $lineHeight 1) $fontSize) - "color" (or (index $filterArgs 5) $textFilterOpts.fontColor) - "font" $font - }} - {{- $f = images.Text (index $filterArgs 0) $opts }} -{{- else if eq $filter "unsharpmask" }} - {{- $ctx = merge $ctx (dict "argsRequired" 3) }} - {{- template "validate-arg-count" $ctx }} - {{- $filterArgs = apply $filterArgs "float" "." }} - {{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 500) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "amount" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }} - {{- template "validate-arg-value" $ctx }} - {{- $ctx = merge $ctx (dict "argName" "threshold" "argValue" (index $filterArgs 2) "min" 0 "max" 1) }} - {{- template "validate-arg-value" $ctx }} - {{- $f = images.UnsharpMask (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }} -{{- end }} - -{{- /* Apply filter. */}} -{{- $fi := $i }} -{{- with $f }} - {{- $fi = $i.Filter . }} -{{- end }} - -{{- /* Render. */}} -{{- $class := "border-1 border-gray-300 dark:border-gray-500" }} -{{- if $example }} -

    Original

    - {{ $alt }} -

    Processed

    - {{ $alt }} -{{- else -}} - {{ $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 -}} diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html deleted file mode 100644 index fee48525a..000000000 --- a/layouts/shortcodes/imgproc.html +++ /dev/null @@ -1,39 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders the given image using the given process specification. - -@param {string} path The path to the image, either a page resource or a global resource. -@param {string} spec The image processing specification. -@param {string} alt The alt attribute of the img element. - -@example {{< imgproc path="sunset.jpg" spec="resize 300x" alt="A sunset" >}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- with $.Get "path" }} - {{- with $i := or ($.Page.Resources.Get .) (resources.Get .) }} - {{- with $spec := $.Get "spec" }} - {{- with $i.Process . }} -
    - {{ $.Get `alt` }} -
    - {{- with $.Inner }} - {{ . }} - {{- else }} - {{ $spec }} - {{- end }} -
    -
    - {{- end }} - {{- else }} - {{- errorf "The %q shortcode requires a 'spec' argument containing the image processing specification. See %s" $.Name $.Position }} - {{- end }} - {{- else }} - {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }} - {{- end }} -{{- else }} - {{- errorf "The %q shortcode requires a 'path' argument indicating the image path. The image must be a page resource or a global resource. See %s" $.Name $.Position }} -{{- end }} diff --git a/layouts/shortcodes/include.html b/layouts/shortcodes/include.html deleted file mode 100644 index 81b0c1d8f..000000000 --- a/layouts/shortcodes/include.html +++ /dev/null @@ -1,20 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders the page using the RenderShortcode method on the Page object. - -You must call this shortcode using the {{% %}} notation. - -@param {string} (positional parameter 0) The path to the page, relative to the content directory. - -@example {{% include "functions/_common/glob-patterns" %}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- with .Get 0 }} - {{- with or ($.Page.GetPage .) (site.GetPage .) }} - {{- .RenderShortcodes }} - {{- else }} - {{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }} - {{- end }} -{{- else }} - {{- errorf "The %q shortcode requires a positional parameter indicating the path of the file to include. See %s" .Name .Position }} -{{- end }} diff --git a/layouts/shortcodes/list-pages-in-section.html b/layouts/shortcodes/list-pages-in-section.html deleted file mode 100644 index f6dfe7275..000000000 --- a/layouts/shortcodes/list-pages-in-section.html +++ /dev/null @@ -1,69 +0,0 @@ -{{- /* -Renders a description list of the pages in the given section. - -Render a subset of the pages in the section by specifying a predefined filter, -and whether to include those pages. - -Filters are defined in the data directory, in the file named page_filters. Each -filter is an array of paths to a file, relative to the root of the content -directory. Hugo will throw an error if the specified filter does not exist, or -if any of the pages in the filter do not exist. - -@param {string} path The path to the section. -@param {string} [filter=""] The name of filter list. -@param {string} [filterType=""] The type of filter, either include or exclude. -@param {string} [titlePrefix=""] The string to prepend to the link title. - -@example {{< list-pages-in-section path=/methods/resources >}} -@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude >}} -@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo >}} -*/}} - -{{/* Initialize. */}} -{{ $filter := or "" (.Get "filter" | lower) }} -{{ $filterType := or (.Get "filterType") "none" | lower }} -{{ $filteredPages := slice }} -{{ $titlePrefix := or (.Get "titlePrefix") "" }} - -{{/* Build slice of filtered pages. */}} -{{ with $filter }} - {{ with index site.Data.page_filters . }} - {{ range . }} - {{ with site.GetPage . }} - {{ $filteredPages = $filteredPages | append . }} - {{ else }} - {{ errorf "The %q shortcode was unable to find %q as specified in the page_filters data file. See %s" $.Name . $.Position }} - {{ end }} - {{ end }} - {{ else }} - {{ errorf "The %q shortcode was unable to find the %q filter in the page_filters data file. See %s" $.Name . $.Position }} - {{ end }} -{{ end }} - -{{/* Render. */}} -{{ with $sectionPath := .Get "path" }} - {{ with site.GetPage . }} - {{ with .RegularPages }} - {{ range $page := .ByTitle }} - {{ if or - (and (eq $filterType "include") (in $filteredPages $page)) - (and (eq $filterType "exclude") (not (in $filteredPages $page))) - (eq $filterType "none") - }} - {{ $linkTitle := .LinkTitle }} - {{ with $titlePrefix }} - {{ $linkTitle = printf "%s%s" . $linkTitle }} - {{ end }} -[{{ $linkTitle }}]({{ $page.RelPermalink }}){{/* Do not indent. */}} -: {{ $page.Description }}{{/* Do not indent. */}} - {{ end }} - {{ end }} - {{ else }} - {{ warnf "The %q shortcode found no pages in the %q section. See %s" $.Name $sectionPath $.Position }} - {{ end }} - {{ else }} - {{ errorf "The %q shortcode was unable to find %q. See %s" $.Name $sectionPath $.Position }} - {{ end }} -{{ else }} - {{ errorf "The %q shortcode requires a 'path' parameter indicating the path to the section. See %s" $.Name $.Position }} -{{ end }} diff --git a/layouts/shortcodes/module-mounts-note.html b/layouts/shortcodes/module-mounts-note.html deleted file mode 100644 index ba89abcbf..000000000 --- a/layouts/shortcodes/module-mounts-note.html +++ /dev/null @@ -1,2 +0,0 @@ -For a more flexible approach to configuring this directory, consult the section -on [module mounts](/configuration/module/#mounts). diff --git a/layouts/shortcodes/new-in.html b/layouts/shortcodes/new-in.html deleted file mode 100644 index 955d0a710..000000000 --- a/layouts/shortcodes/new-in.html +++ /dev/null @@ -1,64 +0,0 @@ -{{/* prettier-ignore-start */ -}} -{{- /* -Renders a callout or badge indicating the version in which a feature was added. - -To render a callout, include descriptive text between the opening and closing -tags. To render a badge,omit the descriptive text and call the shortcode with a -self-closing tag. - -When comparing the current version to the specified version, the "new in" -button will be hidden if any of the following conditions is true: - -- The major version difference exceeds the majorVersionDiffThreshold -- The minor version difference exceeds the minorVersionDiffThreshold - -@param {string} 0 The semantic version string, with or without a leading v. - -@example {{< new-in 0.100.0 />}} - -@example {{{< new-in 0.100.0 >}} - Some descriptive text here. - {{< /new-in >}} -*/ -}} -{{/* prettier-ignore-end */ -}} -{{- $majorVersionDiffThreshold := 0 }} -{{- $minorVersionDiffThreshold := 30 }} -{{- $displayExpirationWarning := true }} - -{{- with $version := .Get 0 | strings.TrimLeft "vV" }} - {{- $majorVersionDiff := sub (index (split hugo.Version ".") 0 | int) (index (split $version ".") 0 | int) }} - {{- $minorVersionDiff := sub (index (split hugo.Version ".") 1 | int) (index (split $version ".") 1 | int) }} - {{- if or (gt $majorVersionDiff $majorVersionDiffThreshold) (gt $minorVersionDiff $minorVersionDiffThreshold) }} - {{- if $displayExpirationWarning }} - {{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }} - {{- end }} - {{- else }} - {{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }} - {{- with $.Inner }} - {{- $inner := strings.TrimSpace . }} - {{- $text := printf "New in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }} - {{ partial "layouts/blocks/alert.html" (dict - "color" "green" - "icon" "exclamation" - "text" $text - ) - }} - {{- else }} - - - - - - New in - v{{ $version }} - - - {{- end }} - {{- end }} -{{- else }} - {{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }} -{{- end }} diff --git a/layouts/shortcodes/per-lang-config-keys.html b/layouts/shortcodes/per-lang-config-keys.html deleted file mode 100644 index f6090d555..000000000 --- a/layouts/shortcodes/per-lang-config-keys.html +++ /dev/null @@ -1,71 +0,0 @@ -{{/* 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.) }} - - -
    - {{- 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 }} - {{ $k }} - {{ end }} - {{- end }} -
    diff --git a/layouts/shortcodes/quick-reference.html b/layouts/shortcodes/quick-reference.html deleted file mode 100644 index 0ac544036..000000000 --- a/layouts/shortcodes/quick-reference.html +++ /dev/null @@ -1,30 +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. - -@example {{% quick-reference section="/functions" %}} -*/ -}} -{{ $section := "" }} -{{ with .Get "section" }} - {{ $section = . }} -{{ else }} - {{ errorf "The %q shortcode requires a 'section' parameter. See %s" .Name .Position }} -{{ end }} - -{{ with site.GetPage $section }} - {{ range .Sections }} -## {{ .LinkTitle }}{{/* Do not indent. */}} -{{ .Description }}{{/* Do not indent. */}} - {{ .Content }} - {{ with .Pages }} - {{ range . }} -[{{ .LinkTitle }}]({{ .RelPermalink }}){{/* Do not indent. */}} -: {{ .Description }}{{/* Do not indent. */}} - {{ end }} - {{ end }} - {{ end }} -{{ else }} - {{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }} -{{ end }} diff --git a/layouts/shortcodes/root-configuration-keys.html b/layouts/shortcodes/root-configuration-keys.html deleted file mode 100644 index 46a6e074f..000000000 --- a/layouts/shortcodes/root-configuration-keys.html +++ /dev/null @@ -1,45 +0,0 @@ -{{/* 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 "%s" .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 -}} diff --git a/layouts/shortcodes/syntax-highlighting-styles.html b/layouts/shortcodes/syntax-highlighting-styles.html deleted file mode 100644 index 297849cef..000000000 --- a/layouts/shortcodes/syntax-highlighting-styles.html +++ /dev/null @@ -1,70 +0,0 @@ -{{- /* -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" ` -Example -`}} -{{- $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") -`}} -{{- $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 }} diff --git a/layouts/single.html b/layouts/single.html new file mode 100644 index 000000000..2e9e4f379 --- /dev/null +++ b/layouts/single.html @@ -0,0 +1,80 @@ +{{ define "main" }} + {{ $ttop := debug.Timer "single" }} +
    + {{ partial "layouts/docsheader.html" . }} +
    + {{ with .Params.description }} +
    + {{ . | markdownify }} +
    + {{ end }} + {{ if .Params.show_publish_date }} + {{ with .PublishDate }} +

    + {{ partial "layouts/date.html" . }} +

    + {{ end }} + {{ end }} + {{ $t := debug.Timer "single.categories" }} + {{ $categories := .GetTerms "categories" }} + {{ with $categories }} +
    + {{ range . }} + {{ $text := .LinkTitle }} + {{ $class := "" }} + {{ range (slice true false ) }} + {{ $color := partial "helpers/funcs/color-from-string.html" (dict "text" $text "dark" . "--single" "green" ) }} + + {{ $prefix := "" }} + {{ if . }} + {{ $prefix = "dark:" }} + {{ end }} + {{ $class = printf "%sbg-%s-%d %stext-%s-%d border %sborder-%s-%d" + $prefix $color.color $color.shade1 + $prefix $color.color $color.shade2 + $prefix $color.color $color.shade3 + }} + {{ end }} + + + + {{ .LinkTitle }} + + {{ end }} +
    + {{ end }} + {{ $t.Stop }} + + {{ if .Params.functions_and_methods.signatures }} +
    + {{- partial "docs/functions-signatures.html" . -}} + {{- partial "docs/functions-return-type.html" . -}} + {{- partial "docs/functions-aliases.html" . -}} +
    + {{ end }} + {{ $t := debug.Timer "single.content" }} + {{ .Content }} + {{ $t.Stop }} + {{ $t := debug.Timer "single.page-edit" }} + {{ partial "layouts/page-edit.html" . }} + {{ $t.Stop }} +
    +
    + {{ $ttop.Stop }} +{{ end }} + +{{ define "rightsidebar_content" }} + {{/* in-this-section.html depends on these being reneredc first. */}} + {{ $related := partial "layouts/related.html" . }} + {{ $toc := partial "layouts/toc.html" . }} + {{ if not .Params.hide_in_this_section }} + {{ partial "layouts/in-this-section.html" . }} + {{ end }} + {{ $related }} + {{ if $.Store.Get "hasToc" }} + {{ $toc }} + {{ end }} +{{ end }} diff --git a/netlify.toml b/netlify.toml index 67c146cad..c24a32a60 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,7 @@ command = "hugo --gc --minify" [build.environment] - HUGO_VERSION = "0.145.0" + HUGO_VERSION = "0.146.7" [context.production.environment] HUGO_ENV = "production" diff --git a/package.hugo.json b/package.hugo.json new file mode 100644 index 000000000..24ffc7ff5 --- /dev/null +++ b/package.hugo.json @@ -0,0 +1,25 @@ +{ + "name": "hugoDocs", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "", + "devDependencies": { + "@awmottaz/prettier-plugin-void-html": "~1.8.0", + "@tailwindcss/cli": "~4.1.0", + "@tailwindcss/typography": "~0.5.16", + "prettier": "~3.5.3", + "prettier-plugin-go-template": "~0.0.15", + "tailwindcss": "~4.1.0" + }, + "dependencies": { + "@alpinejs/focus": "~3.14.9", + "@alpinejs/persist": "~3.14.9", + "@hotwired/turbo": "~8.0.13", + "alpinejs": "~3.14.9" + } +}