Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

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

View File

@@ -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 }}
<blockquote {{- with .Attributes.class }}class="{{ . }}"{{- end }}>
{{ .Text }}
</blockquote>
{{- end }}

View File

@@ -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 }}
<details class="cursor-pointer" {{ $open }}>
<summary>{{ $summary }}</summary>
{{- end }}
<div
x-data
class="render-hook-codeblock font-mono not-prose relative mt-6 mb-8 border-1 border-gray-200 dark:border-gray-800 bg-light dark:bg-dark">
{{- $fileSelectClass := "select-none" }}
{{- if $copy }}
{{- $fileSelectClass = "select-text" }}
<svg
class="absolute right-4 top-2 z-30 text-blue-600 hover:text-blue-500 dark:text-gray-400 dark:hover:text-gray-300 cursor-pointer w-6 h-6"
@click="$copy($refs.code)">
<use href="#icon--copy"></use>
</svg>
{{- end }}
{{- with $file }}
<div
class="san-serif text-sm inline-block leading-none pl-2 py-3 bg-gray-300 dark:bg-slate-700 w-full {{ $fileSelectClass }}
">
{{ . }}
</div>
{{- end }}
<div x-ref="code">
{{- transform.Highlight (strings.TrimSpace .Inner) $lang .Options }}
</div>
</div>
{{- if $details }}
</details>
{{- end }}

View File

@@ -1,10 +0,0 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}
{{- if in (slice 2 3 4 6) .Level }}{{" " -}}
<a class="anchor" name="{{ .Anchor }}"></a>
<a class="inline-flex items-center" href="#{{ .Anchor | safeURL }}" aria-label="Anchor">
<svg class="fill-primary hover:fill-primary/70 w-4 h-4">
<use href="#icon--anchor"></use>
</svg>
</a>
{{- end -}}
</h{{ .Level }}>

View File

@@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}}
{{- /*
@@ -75,8 +76,8 @@ either of these shortcodes in conjunction with this render hook.
@context {string} Title The link title.
@returns {template.html}
*/}}
*/ -}}
{{/* prettier-ignore-end */ -}}
{{- /* Initialize. */}}
{{- $renderHookName := "link" }}
@@ -185,24 +186,25 @@ either of these shortcodes in conjunction with this render hook.
{{- end }}
{{- /* Render anchor element. */ -}}
<a aria-label="{{ .PlainText }}"
{{- with .Title }} title="{{ . }}" {{- end }}
<a
{{- 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" }}
{{- /*
Validates the fragment portion of a link destination.
Validates the fragment portion of a link destination.
@context {string} contentPath The page containing the link.
@context {string} 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.
@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. */}}
@@ -248,20 +250,20 @@ either of these shortcodes in conjunction with this render hook.
{{- define "partials/inline/h-rh-l/get-glossary-link-attributes.html" }}
{{- /*
Returns the anchor element attributes for a link to the given glossary term.
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
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.
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.
@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.. */}}
@@ -289,6 +291,7 @@ either of these shortcodes in conjunction with this render hook.
"localized" "localization"
"paginating" "paginate"
"walking" "walk"
"ci/cd" "cicd"
}}
{{- /* Verify that a glossary term page exists for the given term. */}}
@@ -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

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

View File

@@ -0,0 +1,31 @@
<div class="overflow-x-auto">
<table
{{- range $k, $v := .Attributes }}
{{- if $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}>
<thead>
{{- range .THead }}
<tr>
{{- range . }}
<th {{- with .Alignment }} class="!text-{{ . }}"{{- end }}>
{{- .Text -}}
</th>
{{- end }}
</tr>
{{- end }}
</thead>
<tbody>
{{- range .TBody }}
<tr>
{{- range . }}
<td {{- with .Alignment }} class="!text-{{ . }}"{{- end }}>
{{- .Text -}}
</td>
{{- end }}
</tr>
{{- end }}
</tbody>
</table>
</div>

View File

@@ -1,14 +1,9 @@
<!doctype html>
<html
class="h-full antialiased scheme-light dark:scheme-dark"
lang="{{ with site.Language.LanguageCode }}
{{ . }}
{{ else }}
en-us
{{ end }}
">
lang="{{ or site.Language.LanguageCode `en-US` }}">
<head>
<meta charset="utf-8" />
<meta charset="utf-8">
<title>
{{ .Title }}
</title>
@@ -19,7 +14,7 @@
</style>
<meta
name="description"
content="{{ .Description | default site.Params.description }}" />
content="{{ .Description | default site.Params.description }}">
{{ partial "layouts/head/head-js.html" . }}
{{ with (templates.Defer (dict "key" "global")) }}
{{ $t := debug.Timer "tailwindcss" }}
@@ -34,9 +29,16 @@
{{ end }}
{{ $t.Stop }}
{{ end }}
{{ $noop := .WordCount }}
{{ if .Page.Store.Get "hasMath" }}
<link
href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css"
rel="stylesheet">
{{ end }}
{{ partial "layouts/head/head.html" . }}
</head>
<body class="flex flex-col min-h-full bg-white dark:bg-blue-950">
<body
class="flex flex-col min-h-full bg-white dark:bg-blue-950 kind-{{ .Kind }}">
{{ partial "layouts/hooks/body-start.html" . }}
{{/* Layout. */}}
{{ block "header" . }}
@@ -46,7 +48,8 @@
{{ end }}
<div class="flex w-full xl:w-6xl h-full flex-auto mx-auto">
<main
class="flex-1 mx-auto lg:mx-0 w-full max-w-3x lg:max-w-3x pt-8 lg:pt-14 pb-20 px-main">
class="flex-1 mx-auto lg:mx-0 w-full max-w-3x lg:max-w-3x pt-8 lg:pt-14 pb-20 px-main print:pt-0">
{{ partial "layouts/hooks/body-main-start.html" . }}
{{ block "main" . }}{{ end }}
</main>
{{ block "rightsidebar" . }}
@@ -58,6 +61,8 @@
</div>
{{/* Common icons. */}}
{{ partial "layouts/icons.html" . }}
{{/* Common templates. */}}
{{ partial "layouts/templates.html" . }}
{{/* Footer. */}}
{{ block "footer" . }}
{{ partial "layouts/footer.html" . }}

View File

@@ -1,15 +1,12 @@
{{ define "main" }}
{{ $pages := "" }}
{{ $showDate := false }}
{{ 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 = partial "news/get-news-items.html" . }}
{{ $showDate = true }}
{{ else }}
{{ $pages = .Pages }}
{{ $pages = $pages.ByPublishDate.Reverse }}
{{ end }}
{{ end }}
@@ -23,23 +20,25 @@
{{ end }}
<a
class="flex col-span-1 a--block cursor-pointer flex-col group border p-3 sm:p-4 hover:shadow-md dark:shadow-slate-800 border-gray-300 dark:border-gray-800 m-0"
href="{{ .RelPermalink }}">
{{ if $showDate }}
<p
class="text-gray-500 dark:text-gray-400 text-sm/5 md:text-base/2 mb-2 sm:mb-4">
{{ .Date.Format "January 2, 2006" }}
</p>
href="{{ or .Params.permalink .RelPermalink }}">
{{ if .Params.show_publish_date }}
{{ with .PublishDate }}
<p
class="text-gray-500 dark:text-gray-400 text-sm/5 md:text-base/2 mb-2 sm:mb-4">
{{ partial "layouts/date.html" . }}
</p>
{{ end }}
{{ end }}
<h3
class="text-lg/6 md:text-2xl tracking-tight p-0 -mt-1 sm:mt-0 mb-1 sm:mb-2 text-primary group-hover:text-primary/70 overflow-hidden">
{{ .LinkTitle }}
</h3>
{{ with .Params.action.signatures }}
{{ with .Params.functions_and_methods.signatures }}
{{/* Set in functions and methods pages. */}}
{{ with $signature := index . 0 }}
{{ if $.Params.action.returnType }}
{{ $signature = printf "%s ⟼ %s" $signature $.context.Params.action.returnType }}
{{ if $.Params.functions_and_methods.returnType }}
{{ $signature = printf "%s ⟼ %s" $signature $.context.Params.functions_and_methods.returnType }}
{{ end }}
<div
class="font-mono font-light text-sm whitespace-nowrap mb-2 sm:mb-4 p-2 bg-slate-50 dark:bg-slate-700 border-0 mr-8 overflow-x-auto">
@@ -56,6 +55,9 @@
{{ (or .Params.description .Summary) | plainify | safeHTML }}
{{ end }}
</p>
{{ if and hugo.IsDevelopment site.Params.debug.display_page_metadata }}
{{ partial "helpers/debug/list-item-metadata.html" . }}
{{ end }}
</a>
{{ end }}
</div>

View File

@@ -0,0 +1,33 @@
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Hugo News</title>
<description>Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility.</description>
<link>{{ .Permalink }}</link>
<generator>Hugo {{ hugo.Version }}</generator>
<language>{{ or site.Language.LanguageCode site.Language.Lang }}</language>
{{- with site.Copyright }}
<copyright>{{ . }}</copyright>
{{- end }}
{{- with .OutputFormats.Get "rss" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .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 }}
<lastBuildDate>{{ (index $pages 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{- range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ or .Params.permalink .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid>{{ or .Params.permalink .Permalink }}</guid>
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
</channel>
</rss>

View File

@@ -1,14 +1,21 @@
{{ define "main" }}
{{ $ttop := debug.Timer "single" }}
<article class="max-w-5xl lg:max-w-3xl">
<article class="max-w-5xl lg:max-w-3xl" id="article">
{{ partial "layouts/docsheader.html" . }}
<div class="content" id="content">
<div class="content">
{{ with .Params.description }}
<div class="lead">
{{ . | markdownify }}
</div>
{{ end }}
{{ if .Params.show_publish_date }}
{{ with .PublishDate }}
<p
class="text-gray-500 dark:text-gray-400 text-sm/5 md:text-base/2 mb-2 sm:mb-4">
{{ partial "layouts/date.html" . }}
</p>
{{ end }}
{{ end }}
{{ $t := debug.Timer "single.categories" }}
{{ $categories := .GetTerms "categories" }}
{{ with $categories }}
@@ -41,7 +48,7 @@
{{ end }}
{{ $t.Stop }}
{{ if .Params.action.signatures }}
{{ if .Params.functions_and_methods.signatures }}
<div class="mb-4 not-prose">
{{- partial "docs/functions-signatures.html" . -}}
{{- partial "docs/functions-return-type.html" . -}}
@@ -67,5 +74,7 @@
{{ partial "layouts/in-this-section.html" . }}
{{ end }}
{{ $related }}
{{ $toc }}
{{ if $.Store.Get "hasToc" }}
{{ $toc }}
{{ end }}
{{ end }}