theme: Format layouts

```
npx prettier --write layouts
```
This commit is contained in:
Bjørn Erik Pedersen 2025-02-18 10:31:09 +01:00
parent aa3cd839a2
commit e68431034e
28 changed files with 154 additions and 114 deletions

View File

@ -2,7 +2,6 @@
**/icons.html
# These are whitespace sensitive.
layouts/_default/_markup/render-code*
layouts/shortcodes/glossary.html
# Odd template syntax.
layouts/_default/_markup/render-heading*
@ -13,3 +12,4 @@ layouts/partials/layouts/head/head.html
# Auto generated.
assets/css/components/chroma*.css
assets/jsconfig.json

View File

@ -7,7 +7,7 @@
<img
src="{{ `images/gopher-side_color.svg` | relURL }}"
alt="gopher"
class="w-32 ml-12 float-right" />
class="w-32 ml-12 float-right">
</h1>
<div class="mt-10 flex items-center justify-center gap-x-6">

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}}
{{- /*
@ -76,7 +77,7 @@ either of these shortcodes in conjunction with this render hook.
@returns {template.html}
*/}}
{{/* prettier-ignore-end */ -}}
{{- /* Initialize. */}}
{{- $renderHookName := "link" }}
@ -185,14 +186,16 @@ either of these shortcodes in conjunction with this render hook.
{{- end }}
{{- /* Render anchor element. */ -}}
<a aria-label="{{ .PlainText }}"
{{- with .Title }} title="{{ . }}" {{- end }}
<a
aria-label="{{ .PlainText }}"
{{- with .Title }}title="{{ . }}"{{- end }}
{{- range $k, $v := $attrs }}
{{- if $v }}
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr }}
{{- end }}
{{- end -}}
>{{ .Text }}</a>
>{{ .Text }}</a
>
{{- define "partials/inline/h-rh-l/validate-fragment.html" }}
{{- /*
@ -308,7 +311,7 @@ either of these shortcodes in conjunction with this render hook.
{{- end }}
{{- /* Create the href attribute. */}}
{{- $href := ""}}
{{- $href := "" }}
{{- if $termActual }}
{{- $href = fmt.Printf "%s#%s" $glossaryPage.RelPermalink (anchorize $termActual) }}
{{- end }}

View File

@ -1,9 +1,9 @@
{{ define "main" }}
<div class="flex flex-col w-full p-0 m-0">
{{ partial "layouts/home/opensource.html" . }}
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14">
{{ partial "layouts/home/sponsors.html" (dict "ctx" . "gtag" "home" ) }}
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14">
{{ partial "layouts/home/features.html" . }}
</div>
{{ end }}
@ -15,7 +15,7 @@
<img
src="{{ `images/hugo-logo-wide.svg`| relURL }}"
alt="Hugo Logo"
class="w-64 aspect-3/1 mx-auto mb-8" />
class="w-64 aspect-3/1 mx-auto mb-8">
<h1
class="text-4xl font-bold tracking-tight text-balance text-gray-900 dark:text-gray-300 sm:text-6xl">
The worlds fastest framework for building websites

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{/*
Parses the serialized data from the given URL and returns a map or an array.
@ -8,7 +9,7 @@ Supports CSV, JSON, TOML, YAML, and XML.
@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }}
*/}}
{{/* prettier-ignore-end */ -}}
{{ $url := . }}
{{ $data := dict }}
{{ with try (resources.GetRemote $url) }}

View File

@ -5,7 +5,7 @@
<link
rel="stylesheet"
href="{{ $r.RelPermalink }}"
{{ template `render-attributes` $attr }} />
{{ template `render-attributes` $attr }}>
{{ else }}
{{ with $r | minify | fingerprint }}
<link
@ -13,7 +13,7 @@
href="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous"
{{ template `render-attributes` $attr }} />
{{ template `render-attributes` $attr }}>
{{ end }}
{{ end }}

View File

@ -9,17 +9,17 @@
<source
srcset="{{ $imageWebp.RelPermalink }}"
type="image/webp"
media="(min-width: 1200px)" />
media="(min-width: 1200px)">
<source
srcset="{{ $image.RelPermalink }}"
type="image/jpeg"
media="(min-width: 1200px)" />
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp" />
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg" />
media="(min-width: 1200px)">
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp">
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg">
<img
class="{{ $class }}"
src="{{ $image1x.RelPermalink }}"
alt=""
width="{{ $image1x.Width }}"
height="{{ $image1x.Height }}" />
height="{{ $image1x.Height }}">
</picture>

View File

@ -1,4 +1,5 @@
<footer class="print:hidden bg-blue-950 mt-8 sm:mt-24 border-t-1 border-gray-800">
<footer
class="print:hidden bg-blue-950 mt-8 sm:mt-24 border-t-1 border-gray-800">
<div class="mx-auto max-w-7xl pt-16 pb-8 sm:pt-18 lg:pt-20">
<div class="xl:grid xl:grid-cols-3 xl:gap-8">
{{/* Column 1 */}}
@ -9,13 +10,13 @@
href="https://github.com/gohugoio/hugo/graphs/contributors"
class="text-blue-300 hover:underline"
>Hugo Authors</a
><br />
><br>
</div>
<img
src="/images/hugo-logo-wide.svg"
alt="Hugo Logo"
class="aspect-3/1 w-40" />
class="aspect-3/1 w-40">
<ul class="space-y-2 text-gray-200">
<li class="hover:text-white">

View File

@ -20,6 +20,6 @@
height="{{ .Height }}"
@load="$event.target.classList.remove('_opacity-0')"
alt="QR code linking to {{ $.page.Permalink }}"
class="{{ $img_class }}" />
class="{{ $img_class }}">
{{ end }}
{{ end }}

View File

@ -1,5 +1,5 @@
<div class="print:hidden">
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-16" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-16">
<div class="text-gray-800 dark:text-gray-300 font-semibold">
Last updated:

View File

@ -5,6 +5,7 @@
{{ $fillColor = "fill-slate-500 dark:fill-slate-400" }}
{{ end }}
<button
{{ if .standalone }}
x-data @click="$dispatch('search-toggle')"
@ -13,7 +14,7 @@
aria-label="Search"
class="{{ $textColor }} grid cursor-pointer w-full lg:w-56 grid-cols-[auto_1fr_auto] items-center rounded-md px-2 sm:px-4 py-2 text-left text-xs/6 lg:text-sm/6 outline-0 sm:outline-1 -outline-offset-1 outline-gray-600">
<svg
class="{{ $fillColor}} pointer-events-none -ml-0.5 mr-2 size-5 sm:size-4">
class="{{ $fillColor }} pointer-events-none -ml-0.5 mr-2 size-5 sm:size-4">
<use href="#icon--search"></use>
</svg>
<span class="hidden lg:inline">Search docs</span>

View File

@ -34,7 +34,7 @@
arial-label="Search"
class="text-gray-800 dark:text-gray-100 bg-white/40 dark:bg-gray-900 shadow rounded border-0 p-3 w-full"
placeholder="Search docs"
x-ref="input" />
x-ref="input">
</div>
</div>
<div class="relative mt-6 flex-1 px-4 sm:px-6">

View File

@ -1,4 +1,4 @@
<meta property="og:title" content="{{ .Title }}" />
<meta property="og:title" content="{{ .Title }}">
<meta
property="og:description"
content="{{ with .Description }}
@ -9,56 +9,56 @@
{{ else }}
{{ with .Site.Params.description }}{{ . }}{{ end }}
{{ end }}
{{ end }}" />
{{ end }}">
<meta
property="og:type"
content="{{ if .IsPage }}
article
{{ else }}
website
{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
{{- with $.Params.images -}}
{{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />
<meta property="og:image" content="{{ . | absURL }}">
{{ end -}}
{{- else -}}
{{- $featured := partial "opengraph/get-featured-image.html" . }}
{{- with $featured -}}
<meta property="og:image" content="{{ $featured.Permalink }}" />
<meta property="og:image" content="{{ $featured.Permalink }}">
{{- else -}}
{{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}" />
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end -}}
{{- end -}}
{{- end -}}
{{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
<meta property="article:section" content="{{ .Section }}">
{{ with .PublishDate }}
<meta
property="article:published_time"
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end }}
{{ with .Lastmod }}
<meta
property="article:modified_time"
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end }}
{{- end -}}
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}">{{ end }}
{{- with .Params.locale }}
<meta property="og:locale" content="{{ . }}" />
<meta property="og:locale" content="{{ . }}">
{{ end }}
{{- with .Site.Params.title }}
<meta property="og:site_name" content="{{ . }}" />
<meta property="og:site_name" content="{{ . }}">
{{ end }}
{{- with .Params.videos }}
{{- range . }}
<meta property="og:video" content="{{ . | absURL }}" />
<meta property="og:video" content="{{ . | absURL }}">
{{ end }}
{{ end }}
@ -71,7 +71,7 @@
{{- $series := index $siteSeries ($name | urlize) }}
{{- range $page := first 6 $series.Pages }}
{{- if ne $page.Permalink $permalink }}
<meta property="og:see_also" content="{{ $page.Permalink }}" />
<meta property="og:see_also" content="{{ $page.Permalink }}">
{{ end }}
{{- end }}
{{ end }}
@ -80,5 +80,5 @@
{{- /* Facebook Page Admin ID for Domain Insights */}}
{{- with site.Params.social.facebook_admin }}
<meta property="fb:admins" content="{{ . }}" />
<meta property="fb:admins" content="{{ . }}">
{{ end }}

View File

@ -3,5 +3,4 @@
<dt>{{ .Name }}</dt>
<dd>{{ with .Aliases }}{{ delimit . ", " }}{{ end }}</dd>
{{ end }}
</dl>
</dl>

View File

@ -9,6 +9,7 @@
{{ $fields := after 3 .Params }}
{{ $list := where $list $filter1 $filter2 $filter3 }}
<table class="table table-bordered">
<tr>
{{ range $fields }}
@ -28,10 +29,11 @@
strings.ReplaceRE `\[` "<ol><li>" |
strings.ReplaceRE `\s` "</li><li>" |
strings.ReplaceRE `\]` "</li></ol>" |
safeHTML }}
safeHTML
}}
{{ else }}
{{ $tdContent }}
{{ end}}
{{ end }}
</td>
{{ end }}
</tr>

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a callout indicating the version in which a feature was deprecated.
@ -16,6 +17,7 @@
{{< /new-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 }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders an absolute URL to the source code for an embedded template.
@ -11,7 +12,7 @@ embedded_templates.toml file in the data directory.
@example {{% et robots.txt %}}
@example {{% et filename=robots.txt %}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- /* Get parameters. */}}
{{- $filename := "" -}}
{{- if .IsNamedParams -}}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders the definition of the given glossary term.
@ -7,11 +8,13 @@ Renders the definition of the given glossary term.
@example {{% glossary-term float %}}
@example {{% glossary-term "floating point" %}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- with .Get 0 }}
{{- $path := printf "/quick-reference/glossary/%s" (urlize .) }}
{{- with site.GetPage $path }}
{{/* prettier-ignore-start */ -}}
{{ .RenderShortcodes }}&nbsp;{{/* Do not indent. Do not remove non-breaking space. */}}
{{/* prettier-ignore-end */ -}}
{{- else }}
{{- errorf "The glossary term (%s) shortcode was unable to find %s: see %s" $.Name $path $.Position }}
{{- end }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders the glossary of terms.
@ -54,3 +55,4 @@ shortcode.
{{- else }}
{{- errorf "The %q shortcode was unable to get %s: see %s" .Name $path .Position}}
{{- end }}
{{/* prettier-ignore-end */ -}}

View File

@ -1,8 +1,8 @@
{{- /*
Returns syntax-highlighted code from the given text.
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.
This is useful as a terse way to highlight inline code snippets. Calling the
highlight shortcode for inline snippets is verbose.
*/}}
{{- $code := .Inner | strings.TrimSpace }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders the given image using the given filter, if any.
@ -84,7 +85,7 @@ Renders the given image using the given filter, if any.
>}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- /* Initialize. */}}
{{- $alt := "" }}
{{- $src := "" }}
@ -105,7 +106,7 @@ Renders the given image using the given filter, if any.
{{- /* Get and validate parameters. */}}
{{- with .Get "alt" }}
{{- $alt = .}}
{{- $alt = . }}
{{- end }}
{{- with .Get "src" }}
@ -138,7 +139,7 @@ Renders the given image using the given filter, if any.
{{- if in (slice "false" false 0) (.Get "example") }}
{{- $example = false }}
{{- else if in (slice "true" true 1) (.Get "example")}}
{{- else if in (slice "true" true 1) (.Get "example") }}
{{- $example = true }}
{{- end }}
@ -334,11 +335,23 @@ Renders the given image using the given filter, if any.
{{- end }}
{{- if $example }}
<p>Original</p>
<img class="{{ $class}}" style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
<img
class="{{ $class }}"
style="width: initial;"
src="{{ $i.RelPermalink }}"
alt="{{ $alt }}">
<p>Processed</p>
<img class="{{ $class }}" style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
<img
class="{{ $class }}"
style="width: initial;"
src="{{ $fi.RelPermalink }}"
alt="{{ $alt }}">
{{- else -}}
<img class='di' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
<img
class="di"
style="width: initial;"
src="{{ $fi.RelPermalink }}"
alt="{{ $alt }}">
{{- end }}
{{- define "validate-arg-count" }}
@ -387,5 +400,5 @@ Renders the given image using the given filter, if any.
{{- end }}
{{- end }}
{{- end }}
{{- return $r}}
{{- return $r }}
{{- end -}}

View File

@ -19,7 +19,7 @@
src="{{ .RelPermalink }}"
width="{{ .Width }}"
height="{{ .Height }}"
alt="{{ $.Get `alt` }}" />
alt="{{ $.Get `alt` }}">
<figcaption class="not-prose text-sm">
{{- with $.Inner }}
{{ . }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders the page using the RenderShortcode method on the Page object.
@ -8,7 +9,7 @@ You must call this shortcode using the {{% %}} notation.
@example {{% include "functions/_common/glob-patterns" %}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- with .Get 0 }}
{{- with or ($.Page.GetPage .) (site.GetPage .) }}
{{- .RenderShortcodes }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a description list of the pages in the given section.
@ -30,9 +31,9 @@ omitElementIDs to true for the subset.
@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo >}}
@example {{< list-pages-in-section path=/functions/images filter=some_filter filterType=exclude titlePrefix=foo omitElementIDs=true >}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- /* Initialize. */}}
{{- $filter := or "" (.Get "filter" | lower)}}
{{- $filter := or "" (.Get "filter" | lower) }}
{{- $filterType := or (.Get "filterType") "none" | lower }}
{{- $filteredPages := slice }}
{{- $titlePrefix := or (.Get "titlePrefix") "" }}
@ -41,7 +42,7 @@ omitElementIDs to true for the subset.
{{- /* Get boolean parameters. */}}
{{- if in (slice "false" false 0) (.Get "omitElementIDs") }}
{{- $omitElementIDs = false }}
{{- else if in (slice "true" true 1) (.Get "omitElementIDs")}}
{{- else if in (slice "true" true 1) (.Get "omitElementIDs") }}
{{- $omitElementIDs = true }}
{{- end }}
@ -80,7 +81,9 @@ omitElementIDs to true for the subset.
{{- $id := path.Join .File.Dir .File.ContentBaseName | replaceRE `[\|/]` ":" | lower }}
{{- $idAttribute = printf " id=%q" $id }}
{{- end }}
<dt {{- $idAttribute | safeHTMLAttr }}><a href="{{ $page.RelPermalink }}">{{ $linkTitle }}</a></dt>
<dt {{- $idAttribute | safeHTMLAttr }}>
<a href="{{ $page.RelPermalink }}">{{ $linkTitle }}</a>
</dt>
<dd>{{- $page.Description | $page.RenderString }}</dd>
{{- end }}
{{- end }}

View File

@ -1 +1,3 @@
Also see [Module Mounts Config](/hugo-modules/configuration/#module-configuration-mounts) for an alternative way to configure this directory.
Also see [Module Mounts
Config](/hugo-modules/configuration/#module-configuration-mounts) for an
alternative way to configure this directory.

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a callout or badge indicating the version in which a feature was added.
@ -22,6 +23,7 @@
Some descriptive text here.
{{< /new-in >}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- $majorVersionDiffThreshold := 0 }}
{{- $minorVersionDiffThreshold := 30 }}
{{- $displayExpirationWarning := true }}

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /*
Renders a callout.
@ -9,6 +10,7 @@
Some descriptive text here.
{{< /note >}}
*/}}
{{/* prettier-ignore-end */ -}}
{{- $text := .Inner | strings.TrimSpace | .Page.RenderString (dict "display" "block") }}
{{- partial "layouts/blocks/alert.html" (dict
"color" "blue"

View File

@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{/*
Renders the child sections of the given top-level section, listing each child's immediate descendants.
@ -37,3 +38,4 @@ Renders the child sections of the given top-level section, listing each child's
{{ else }}
{{ errorf "The %q shortcodes was unable to find the %q section. See %s" .Name $section .Position }}
{{ end }}
{{/* prettier-ignore-end */ -}}