huge upgrade to theme and pagefind search bar.

This commit is contained in:
2026-04-17 13:28:48 -06:00
parent a6a38f7ea7
commit 235d40da0b
442 changed files with 18933 additions and 2893 deletions

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}">
<head>
{{ partial "docs/html-head" . }}
{{ partial "docs/inject/head" . }}
<style>
.not-found {
height: 100vh;
width: 100vw;
}
.not-found h1 {
font-size: 10vmin;
font-weight: lighter;
cursor: default;
}
.not-found h1 span {
display: inline-block;
transition: transform .2s ease-out, opacity .2s ease-out;
}
.not-found h1:hover span {
transition-duration: 1s;
transform: translate(var(--drift-x), var(--drift-y)) rotate(var(--rotate-end));
opacity: 0;
}
.not-found h1:hover span:nth-child(1) {
--drift-x: -1em;
--drift-y: 1em;
--rotate-end: -90deg;
}
.not-found h1:hover span:nth-child(2) {
--drift-x: -1em;
--drift-y: -2em;
--rotate-end: 45deg;
}
.not-found h1:hover span:nth-child(3) {
--drift-x: 3em;
--drift-y: 1em;
--rotate-end: 120deg;
}
</style>
</head>
<body class="not-found flex justify-center align-center">
<main class="text-center">
<h1>
<span>Page</span>
<span>Not</span>
<span>Found</span>
</h1>
<h3>
<a href="{{ .Site.Home.RelPermalink }}">{{ .Site.Title }}</a>
</h3>
</main>
{{ partial "docs/inject/body" . }}
</body>
</html>

View File

@@ -0,0 +1,9 @@
{{- $attributes := .Attributes -}}
{{- $class := printf "book-hint %s" ($.AlertType | lower) -}}
{{- if isset $attributes "class" -}}
{{- $class = printf "%s %s" $class (index $attributes "class") -}}
{{ end -}}
{{- $attributes = merge $attributes (dict "class" $class) -}}
<blockquote {{ range $key, $value := $attributes }}{{printf "%s='%s'" $key $value | safeHTMLAttr}}{{ end }}>
{{ .Text -}}
</blockquote>

View File

@@ -0,0 +1,13 @@
{{- with .Inner -}}
<span>\[ {{ .| htmlEscape | safeHTML }} \]</span>
{{- end -}}
{{- if not (.Page.Store.Get "katex") -}}
{{- /* Include katex only first time */ -}}
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
{{- /* remove whitespaces */ -}}
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
{{- with resources.Get "katex.json" | minify -}}
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ .Content | safeJS }});"></script>
{{- end -}}
{{- .Page.Store.Set "katex" true -}}
{{- end -}}

View File

@@ -0,0 +1,10 @@
{{- /* remove whitespaces */ -}}
<pre class="mermaid">{{ .Inner | htmlEscape | safeHTML -}}</pre>
{{- if not (.Page.Store.Get "mermaid") -}}
{{- /* Include mermaid only first time */ -}}
<script src="{{ "mermaid.min.js" | relURL }}"></script>
{{- with resources.Get "mermaid.json" | minify -}}
<script>mermaid.initialize({{ .Content | safeJS }})</script>
{{- end -}}
{{- .Page.Store.Set "mermaid" true -}}
{{- end -}}

View File

@@ -0,0 +1,10 @@
{{- with (index .Attributes "filename") -}}
{{- $href := index $.Attributes "href" -}}
{{- if $href -}}
{{- $href = partial "docs/links/portable-link" (dict "Page" $.PageInner "Destination" $href) -}}
{{- end -}}
<div class="book-codeblock-filename">
<a {{ with $href }}href="{{ . }}"{{ end }}>{{ . }}</a>
</div>
{{- end -}}
{{- (transform.HighlightCodeBlock . .Options).Wrapped -}}

View File

@@ -0,0 +1,6 @@
<h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class -}}class="{{ . }}"{{- end -}}>
{{- .Text -}}
{{- if default true .Attributes.anchor -}}
<a class="anchor" href="#{{ .Anchor }}">#</a>
{{- end -}}
</h{{ .Level }}>

View File

@@ -0,0 +1,6 @@
{{- $destination := .Destination -}}
{{- if .Page.Site.Params.BookPortableLinks -}}
{{- $destination = partial "docs/links/portable-image" . -}}
{{- end -}}
<img src="{{ $destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/>
{{- /**/ -}}

View File

@@ -0,0 +1,6 @@
{{- $destination := .Destination -}}
{{- if .Page.Site.Params.BookPortableLinks -}}
{{- $destination = partial "docs/links/portable-link" . -}}
{{- end -}}
<a href="{{ $destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
{{- /**/ -}}

View File

@@ -0,0 +1,8 @@
<h2 class="book-brand">
<a class="flex align-center" href="{{ cond (not .Site.Home.File) .Sites.Default.Home.RelPermalink .Site.Home.RelPermalink }}">
{{- with .Site.Params.BookLogo -}}
<img src="{{ . | relURL }}" alt="{{ partial "docs/text/i18n" "Logo" }}" />
{{- end -}}
<span>{{ .Site.Title }}</span>
</a>
</h2>

View File

@@ -0,0 +1,2 @@
<!-- This partial can be replaced to support other commenting engines -->
{{ partial "disqus.html" . }}

View File

@@ -0,0 +1 @@
<small>{{ .Site.Title }} - {{ .Site.Copyright | .RenderString }}</small>

View File

@@ -0,0 +1,6 @@
<!--
Returns formatted date.
Usage: partial "docs/date" (dict "Date" .Date "Format" .Site.Params.BookDateFormat)
-->
{{- $format := default "January 2, 2006" .Format -}}
{{- return (time.Format $format .Date) -}}

View File

@@ -0,0 +1,24 @@
<div class="flex flex-wrap justify-between">
<div>
{{ if and .GitInfo .Site.Params.BookLastChangeLink }}
{{- $date := partial "docs/date" (dict "Date" .Lastmod "Format" .Site.Params.BookDateFormat) -}}
<a class="flex align-center" href="{{ partial "docs/links/commit" . }}" title='{{ partial "docs/text/i18n" "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
<img src="{{ partial "docs/icon" "calendar" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Calendar" }}" />
<span>{{ $date }}</span>
</a>
{{ end }}
</div>
<div>
{{ if and .File .Site.Params.BookEditLink }}
<a class="flex align-center" href="{{ partial "docs/links/edit" . }}" target="_blank" rel="noopener edit">
<img src="{{ partial "docs/icon" "edit" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Edit" }}" />
<span>{{ partial "docs/text/i18n" "Edit this page" }}</span>
</a>
{{ end }}
</div>
</div>
{{ partial "docs/prev-next" . }}

View File

@@ -0,0 +1,13 @@
<div class="flex align-center justify-between">
<label for="menu-control">
<img src="{{ partial "docs/icon" "menu" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Menu" }}" />
</label>
<h3>{{ partial "docs/title" . }}</h3>
<label for="toc-control">
{{ if partial "docs/toc-show" . }}
<img src="{{ partial "docs/icon" "toc" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Table of Contents" }}" />
{{ end }}
</label>
</div>

View File

@@ -0,0 +1 @@
{{- range $key, $value := . -}} {{- $key | htmlEscape -}}="{{- $value | safeHTMLAttr -}}" {{- end -}}

View File

@@ -0,0 +1 @@
<link rel="icon" href="{{ .Site.Params.BookFavicon | default "favicon.png" | relURL }}" >

View File

@@ -0,0 +1 @@
{{ with partial "docs/title" . }}{{ . }} | {{ end }}{{ .Site.Title -}}

View File

@@ -0,0 +1,60 @@
{{ "<!--" | safeHTML }}
Made with Book Theme
https://github.com/alex-shpak/hugo-book
{{ "-->" | safeHTML }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{{ or .Description .Summary | plainify | htmlUnescape }}">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#343a40">
<meta name="color-scheme" content="light dark">
{{- with .Page.Params.BookHref -}}
<meta http-equiv="Refresh" content="0; url='{{ . }}'" />
{{- end -}}
{{ partial "opengraph.html" . }}
{{ partial "schema.html" . }}
<title>{{ partial "docs/html-head-title" . }}</title>
{{ partial "docs/html-head-favicon" . }}
{{- $manifest := resources.Get "manifest.json" | resources.ExecuteAsTemplate "manifest.json" . }}
<link rel="manifest" href="{{ $manifest.RelPermalink }}">
<link rel="canonical" href="{{ .Permalink }}">
{{- range .Translations }}
<link rel="alternate" hreflang="{{ default .Site.LanguageCode .Language.Lang }}" href="{{ .Permalink }}" title="{{ partial "docs/title" . }}">
{{- end -}}
<!-- Theme stylesheet, you can customize scss by creating `assets/custom.scss` in your website -->
{{- $styles := resources.Get "book.scss" | resources.ExecuteAsTemplate "book.scss" . | css.Sass | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ partial "docs/links/resource-precache" $styles }}" {{ template "integrity" $styles }}>
<!-- Search -->
{{- if default true .Site.Params.BookSearch -}}
{{- $searchJSFile := printf "%s.search.js" .Language.Lang }}
{{- $searchJS := resources.Get "search.js" | resources.ExecuteAsTemplate $searchJSFile . | resources.Minify | resources.Fingerprint }}
<script defer src="{{ "fuse.min.js" | relURL }}"></script>
<script defer src="{{ partial "docs/links/resource-precache" $searchJS }}" {{ template "integrity" $searchJS }}></script>
{{ end -}}
<!-- Service Worker -->
{{- if .Site.Params.BookServiceWorker -}}
{{- $swJS := resources.Get "sw-register.js" | resources.ExecuteAsTemplate "sw.js" . | resources.Minify | resources.Fingerprint }}
<script defer src="{{ $swJS.RelPermalink }}" {{ template "integrity" $swJS }}></script>
{{ end -}}
{{ partial "google_analytics.html" . }}
<!-- RSS -->
{{- with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}
{{- define "integrity" -}}
{{- if (urls.Parse .Permalink).Host -}}
integrity="{{ .Data.Integrity }}" crossorigin="anonymous"
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,2 @@
{{- $icon := resources.Get (printf "icons/%s.svg" .) -}}
{{- return $icon.RelPermalink -}}

View File

@@ -0,0 +1,33 @@
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }}
{{ if (eq $bookTranslatedOnly false ) }}
{{ range .Site.Home.Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
{{ end }}
{{ range .Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
<ul class="book-languages">
<li>
<input type="checkbox" id="languages" class="toggle" />
<label for="languages" class="flex">
<a role="button">
<img src="{{ partial "docs/icon" "translate" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Languages" }}" />
{{ $.Site.Language.LanguageName }}
</a>
<img src="{{ partial "docs/icon" "chevron-right" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Expand" }}" />
</label>
<ul>
{{ range .Site.Languages }}{{ with index $translations .Lang }}
<li>
<a href="{{ cond hugo.IsMultihost .Permalink .RelPermalink }}" class="flex flex-auto">
{{ .Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</li>
</ul>

View File

@@ -0,0 +1,5 @@
{{- return (partial "docs/text/template" (dict "Template" .Site.Params.BookLastChangeLink "Context" (dict
"Site" .Site
"Page" .Page
"GitInfo" .GitInfo
)) | urls.JoinPath) -}}

View File

@@ -0,0 +1,5 @@
{{- return (partial "docs/text/template" (dict "Template" .Site.Params.BookEditLink "Context" (dict
"Site" .Site
"Page" .Page
"Path" (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename)
)) | urls.JoinPath) -}}

View File

@@ -0,0 +1,32 @@
{{- $destination := .Destination -}}
{{- $url := urls.Parse .Destination -}}
{{- $isRemote := $url.IsAbs -}}
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
{{- if and (not $isRemote) (not $isFragment) -}}
{{- $path := strings.TrimPrefix "./" $url.Path -}}
{{- $path = strings.TrimPrefix "/assets/" $path -}}
{{- with (.Page.Resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else with (resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else -}}
{{- $mode := .Page.Site.Params.BookPortableLinks -}}
{{- $message := printf "Image reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
{{- if eq $mode "warning" -}}
{{- warnf $message -}}
{{- else if eq $mode "error" -}}
{{- errorf $message -}}
{{- end -}}
{{- end -}}
{{- with $url.RawQuery -}}
{{- $destination = print $destination "?" . -}}
{{- end -}}
{{- with $url.Fragment -}}
{{- $destination = print $destination "#" . -}}
{{- end -}}
{{- end -}}
{{- return $destination -}}

View File

@@ -0,0 +1,35 @@
{{- $destination := .Destination -}}
{{- $url := urls.Parse .Destination -}}
{{- $isRemote := $url.IsAbs -}}
{{- $isFragment := strings.HasPrefix .Destination "#" -}}
{{- if and (not $isRemote) (not $isFragment) -}}
{{- $path := strings.TrimPrefix "./" $url.Path -}}
{{- $path = strings.TrimSuffix ".md" $path -}}
{{- $path = strings.TrimSuffix "/_index" $path -}}
{{- with (.Page.GetPage $path) -}}
{{- $destination = .RelPermalink -}}
{{- else with (.Page.Resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else with (resources.Get $path) -}}
{{- $destination = .RelPermalink -}}
{{- else -}}
{{- $mode := .Page.Site.Params.BookPortableLinks -}}
{{- $message := printf "Image reference '%s' not found in '%s'" .Destination .Page.RelPermalink -}}
{{- if eq $mode "warning" -}}
{{- warnf $message -}}
{{- else if eq $mode "error" -}}
{{- errorf $message -}}
{{- end -}}
{{- end -}}
{{- with $url.RawQuery -}}
{{- $destination = print $destination "?" . -}}
{{- end -}}
{{- with $url.Fragment -}}
{{- $destination = print $destination "#" . -}}
{{- end -}}
{{- end -}}
{{- return $destination -}}

View File

@@ -0,0 +1,2 @@
{{- site.Store.SetInMap "book-sw-precache" .RelPermalink true -}}
{{- return .RelPermalink -}}

View File

@@ -0,0 +1,59 @@
{{ $bookSection := default "docs" .Site.Params.BookSection }}
{{ if eq $bookSection "*" }}
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}
{{ with .Site.GetPage $bookSection }}
{{ template "book-section-children" (dict "Section" . "CurrentPage" $) }}
{{ end }}
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
<ul>
{{ range (where .Section.Pages "Params.bookHidden" "ne" true) }}
{{ if .IsSection }}
<li {{- if .Params.BookFlatSection }} class="book-section-flat" {{ end -}}>
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
</li>
{{ else if and .IsPage .Content }}
<li>
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}}
{{ $current := eq .CurrentPage .Page }}
{{ $ancestor := .Page.IsAncestor .CurrentPage }}
{{ if .Page.Params.BookCollapseSection }}
<input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
<label for="section-{{ md5 .Page }}" class="flex">
<a {{ if .Page.Content }}href="{{ .Page.RelPermalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}">
{{ template "book-icon-title" .Page -}}
</a>
<img src="{{ partial "docs/icon" "chevron-right" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Expand" }}" />
</label>
{{ else if .Page.Params.BookHref }}
<a href="{{ .Page.Params.BookHref }}" class="{{ if $current }}active{{ end }}" target="_blank" rel="noopener">
{{ template "book-icon-title" .Page -}}
</a>
{{ else if .Page.Content }}
<a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}">
{{ template "book-icon-title" .Page -}}
</a>
{{ else }}
<a>
{{ template "book-icon-title" .Page -}}
</a>
{{ end }}
{{ end }}
{{ define "book-icon-title" }}
{{- with .Page.Params.BookIcon -}}
<img src="{{ partial "docs/icon" . }}" class="book-icon" alt="{{ partial "docs/text/i18n" . }}" />
{{- end -}}
{{- partial "docs/title" .Page -}}
{{ end }}

View File

@@ -0,0 +1,46 @@
<!--
This is template for hugo menus, accepts Page and Menu as context
https://gohugo.io/variables/menus/
-->
{{- if .Menu -}}
{{- template "book-menu-hugo" . -}}
{{- end -}}
{{ define "book-menu-hugo" }}
<ul>
{{- range .Menu -}}
{{- $class := slice -}}
{{- with .Params.class -}}
{{- $class = $class | append . -}}
{{- end -}}
{{- if $.Page.IsMenuCurrent .Menu . -}}
{{- $class = $class | append "active" -}}
{{- end -}}
<li>
{{- $isRemote := (urls.Parse .URL).IsAbs -}}
<a href="{{ .URL }}"
{{- with $class }} class="{{ delimit . " " }}"{{- end -}}
{{- with .Title }} title="{{ . }}"{{- end -}}
{{- if $isRemote }} target="_blank" rel="noopener"{{- end -}}>
{{- .Pre -}}
{{- template "book-menu-title" . -}}
{{- .Post -}}
</a>
{{- with .Children -}}
{{- template "book-menu-hugo" (dict "Page" $.Page "Menu" .) -}}
{{- end -}}
</li>
{{- end -}}
</ul>
{{ end }}
{{ define "book-menu-title" }}
{{- with .Params.BookIcon -}}
<img src="{{ partial "docs/icon" . }}" class="book-icon" alt="{{ partial "docs/text/i18n" . }}" />
{{- end -}}
{{- if .Name -}}
{{- .Name -}}
{{- else if .Page -}}
{{- partial "docs/title" .Page -}}
{{- end -}}
{{ end }}

View File

@@ -0,0 +1,21 @@
<nav>
{{ partial "docs/brand" . }}
{{ partial "docs/search" . }}
{{ if hugo.IsMultilingual }}
{{ partial "docs/languages" . }}
{{ end }}
{{ partial "docs/inject/menu-before" . }}
{{ partial "docs/menu-hugo" (dict "Page" .Page "Menu" .Site.Menus.before) }}
{{ partial "docs/menu-filetree" . }}
{{ partial "docs/menu-hugo" (dict "Page" .Page "Menu" .Site.Menus.after) }}
{{ partial "docs/inject/menu-after" . }}
</nav>
<!-- Restore menu position as soon as possible to avoid flickering -->
{{ $script := resources.Get "menu-reset.js" | resources.Minify }}
{{ with $script.Content }}
<script>{{ . | safeJS }}</script>
{{ end }}

View File

@@ -0,0 +1,28 @@
{{- if .Paginator -}}
<div class="flex flex-wrap justify-between">
<span>
{{- with .Paginator.Prev }}
<a href="{{ .URL }}" class="flex align-center">
<img src="{{ partial "docs/icon" "backward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Backward" }}" />
</a>
{{ end }}
</span>
{{ if gt (len .Paginator.Pagers) 1 }}
<span class="flex gap">
{{- $currentPageNumber := .Paginator.PageNumber -}}
{{- range $pageIndex := (slice -2 -1 0 1 2) -}}
{{- with index $.Paginator.Pagers (add $currentPageNumber $pageIndex -1) -}}
<a {{if ne $currentPageNumber .PageNumber }}href="{{ .URL }}"{{end}}>{{ .PageNumber }}</a>
{{- end -}}
{{- end -}}
</span>
{{ end }}
<span>
{{- with .Paginator.Next }}
<a href="{{ .URL }}" class="flex align-center">
<img src="{{ partial "docs/icon" "forward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Forward" }}" />
</a>
{{ end }}
</span>
</div>
{{- end -}}

View File

@@ -0,0 +1,16 @@
{{ with .Date }}
<div class="flex align-center text-small book-post-date">
<img src="{{ partial "docs/icon" "calendar" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Calendar" }}" />
<span>{{ partial "docs/date" (dict "Date" . "Format" $.Site.Params.BookDateFormat) }}</span>
</div>
{{ end }}
{{ range $taxonomy, $_ := .Site.Taxonomies }}
{{ with $terms := $.GetTerms $taxonomy }}
<div class="text-small">
{{ range $n, $term := $terms }}{{ if $n }}, {{ end }}
<a href="{{ $term.RelPermalink }}">{{ $term.Title }}</a>
{{- end }}
</div>
{{ end }}
{{ end }}

View File

@@ -0,0 +1,18 @@
<div class="flex flex-wrap justify-between">
<div>
{{ with .NextInSection }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<img src="{{ partial "docs/icon" "backward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Backward" }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
</div>
<div>
{{ with .PrevInSection }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ partial "docs/icon" "forward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Forward" }}" />
</a>
{{ end }}
</div>
</div>

View File

@@ -0,0 +1,14 @@
{{ $scratch := newScratch }}
{{ template "recurse" (dict "Scratch" $scratch "Sections" .) }}
{{ define "recurse" }}
{{ range .Sections }}
{{ if and .Content (not .Params.BookHidden) }}
{{ $.Scratch.Add "BookPages" (slice .) }}
{{ end }}
{{ if .IsSection }}
{{ template "recurse" (dict "Scratch" $.Scratch "Sections" .Pages) }}
{{ end }}
{{ end }}
{{ end }}
{{ return $scratch.Get "BookPages" }}

View File

@@ -0,0 +1,31 @@
{{ $bookSection := default "docs" .Site.Params.BookSection }}
{{ if eq $bookSection "*" }}
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}
{{ with .Site.GetPage $bookSection }}
{{ $pages := partialCached "docs/prev-next-cache" .Pages }}
{{ $prev := $pages.Next $ }}
{{ $next := $pages.Prev $ }}
{{- if or $prev $next }}
<div class="flex flex-wrap justify-between">
<span>
{{ with $prev }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<img src="{{ partial "docs/icon" "backward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Backward" }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
</span>
<span>
{{ with $next }}
<a href="{{ .RelPermalink }}" class="flex align-center">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ partial "docs/icon" "forward" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Forward" }}" />
</a>
{{ end }}
</span>
</div>
{{ end -}}
{{ end }}

View File

@@ -0,0 +1,10 @@
{{ if default true .Site.Params.BookSearch }}
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
{{ end }}

View File

@@ -0,0 +1,22 @@
<!-- /* {{ if default true .Site.Params.BookSearch }} */ -->
<!-- /* <div class="book-search hidden"> */ -->
<!-- /* <input id="book-search-input" type="text" */ -->
<!-- /* placeholder="{{ partial "docs/text/i18n" "SearchY" }}" */ -->
<!-- /* aria-label="{{ partial "docs/text/i18n" "SearchZ" }}" */ -->
<!-- /* maxlength="64" data-hotkeys="s/" /> */ -->
<!-- /* <div class="book-search-spinner hidden"></div> */ -->
<!-- /* <ul id="book-search-results"></ul> */ -->
<!-- /* </div> */ -->
<!-- /* <script>document.querySelector(".book-search").classList.remove("hidden")</script> */ -->
<!-- /* {{ end }} */ -->
<!-- {{ if default true .Site.Params.BookSearch }} -->
<!-- <link href="/pagefind/pagefind-ui.css" rel="stylesheet"> -->
<!-- <script src="/pagefind/pagefind-ui.js"></script> -->
<!-- <div id="search"></div> -->
<!-- <script> -->
<!-- window.addEventListener('DOMContentLoaded', (event) => { -->
<!-- new PagefindUI({ element: "#search", showSubResults: true }); -->
<!-- }); -->
<!-- </script> -->
<!-- {{ end }} -->

View File

@@ -0,0 +1,19 @@
<nav>
<ul>
{{ range $term, $_ := .Site.Taxonomies }}
{{ with $.Site.GetPage (printf "/%s" $term | urlize) }}
<li class="book-section-flat">
<a>{{ partial "docs/text/i18n" .Title }}</a>
<ul>
{{ range .Pages }}
<li class="flex align-center">
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
<span>{{ len .Pages }}</span>
</li>
{{ end }}
</ul>
</li>
{{ end }}
{{ end }}
</ul>
</nav>

View File

@@ -0,0 +1 @@
{{- return or (i18n .) . -}}

View File

@@ -0,0 +1,36 @@
{{- /*
This is generic function the helps modifying and merging dictionaries, usually used for html attributes
Logic is executed in order defined below.
partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"keep" (slice "id" "class" "tabindex" "alt" "title" "loading")
"set" (dict "href" "https://")
"merge" (dict "class" "a-class")
"delimiter" " " // Used when merging values
"delete" (slice "src")
)
*/ -}}
{{- $store := newScratch -}}
{{- $allowlist := or (.keep) (slice "id" "class" "tabindex" "dir")}}
{{- range $key, $value := .attributes -}}
{{- if in $allowlist $key -}}
{{- $store.Set $key $value -}}
{{- end -}}
{{- end -}}
{{- range $key, $value := .set -}}
{{- $store.Set $key (print $value) -}}
{{- end -}}
{{- range $key, $value := .merge -}}
{{- $merged := (slice) | append $value | append (or (index $.attributes $key) (slice)) -}}
{{- $delimiter := or ($.delimiter) (" ") }}
{{- $store.Set $key (delimit $merged $delimiter) -}}
{{- end -}}
{{- range $key := .delete -}}
{{- $store.Delete $key -}}
{{- end -}}
{{- return $store.Values -}}

View File

@@ -0,0 +1,9 @@
<!--
Returns rendered string from template and context.
Usage: partial "docs/string-template" (dict "Template" "param={{ . }}" "Context" "Input")
-->
{{- $checksum := . | encoding.Jsonify | crypto.SHA1 | printf "book-%s" -}}
{{- $template := resources.FromString $checksum .Template -}}
{{- $template = $template | resources.ExecuteAsTemplate $checksum .Context -}}
{{- return $template.Content -}}

View File

@@ -0,0 +1,17 @@
<!--
Partial to generate page name from Title or File name.
Accepts Page as context
-->
{{ $title := "" }}
{{ if .LinkTitle }}
{{ $title = .LinkTitle }}
{{ else if .Title }}
{{ $title = .Title }}
{{ else if and .IsSection .File }}
{{ $title = path.Base .File.Dir | humanize | title }}
{{ else if and .IsPage .File }}
{{ $title = .File.BaseFileName | humanize | title }}
{{ end }}
{{ return $title }}

View File

@@ -0,0 +1,5 @@
{{- return and
(not (eq .Params.bookToC false))
(not (eq .Site.Params.BookToC false))
(not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>"))
-}}

View File

@@ -0,0 +1,3 @@
{{ partial "docs/inject/toc-before" . }}
{{ .TableOfContents }}
{{ partial "docs/inject/toc-after" . }}

View File

@@ -0,0 +1,24 @@
{{- if not (.Page.Store.Get "asciinema") -}}
{{- /* Include asciinema player only first time */ -}}
<link rel="stylesheet" href="{{ "asciinema/asciinema-player.css" | relURL }}" />
{{- /* remove whitespaces */ -}}
<script defer src="{{ "asciinema/asciinema-player.min.js" | relURL }}"></script>
{{- /* remove whitespaces */ -}}
<script defer src="{{ "asciinema/asciinema-auto.js" | relURL }}"></script>
{{- .Page.Store.Set "asciinema" true -}}
{{- end -}}
{{- $href := (partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "cast"))) -}}
{{- .Store.Set "asciinema" .Params -}}
{{- .Store.DeleteInMap "asciinema" "cast" -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (dict)
"set" (dict
"id" (printf "asciinema-%d" .Ordinal)
"x-data-cast" $href
"x-data-opts" (.Store.Get "asciinema" | jsonify)
)
"merge" (dict
"class" (slice "asciinema" "book-asciinema")
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}></div>

View File

@@ -0,0 +1,12 @@
{{- $style := or (.Get "style") (.Get 0) "default" -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-badge" $style)
)
) -}}
<span {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- with or (.Get "title") (.Get 1) -}}<span class="book-badge-title">{{ . | plainify }}</span>{{- end -}}
{{- with or (.Get "value") (.Get 2) -}}<span class="book-badge-value">{{ . | plainify }}</span>{{- end -}}
</span>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,18 @@
{{- $href := partial "docs/links/portable-link" (dict "Page" .Page "Destination" (.Get "href")) -}}
{{- $isRemote := (urls.Parse $href).IsAbs -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"set" (dict
"href" $href
"target" "_blank"
"rel" "noopener"
)
"merge" (dict
"class" "book-btn"
)
"delete" (cond $isRemote (slice) (slice "target" "rel"))
) -}}
<a {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- .InnerDeindent -}}
</a>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,20 @@
{{- with .Get "href" -}}
{{- $destination := partial "docs/links/portable-link" (dict "Page" $.Page "Destination" .) -}}
<div class="book-card{{ with $.Get "class" }} {{ . }}{{ end }}"><a href="{{ $destination | safeURL }}">
{{- template "book-card-content" $ -}}
</a></div>
{{- else -}}
<div class="book-card{{ with .Get "class" }} {{ . }}{{ end }}">
{{- template "book-card-content" $ -}}
</div>
{{- end -}}
{{- define "book-card-content" -}}
{{- with .Get "image" -}}
{{- $destination := partial "docs/links/portable-image" (dict "Page" $.Page "Destination" .) -}}
<img src="{{ $destination | safeURL }}" alt="{{ partial "docs/text/i18n" ($.Get "alt" ) }}" />
{{- end -}}
<div class="markdown-inner">
{{ with .Inner }}{{ . }}{{ end -}}
</div>
{{- end -}}

View File

@@ -0,0 +1,33 @@
{{- $ratio := (split (.Get "ratio") ":") -}}
{{- if strings.Contains .InnerDeindent "<--->" -}}
{{- warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns" "flex" "flex-wrap")
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- range $index, $content := split .InnerDeindent "<--->" -}}
{{- $grow := default 1 (index $ratio $index) -}}
<div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};">
{{- $content | safeHTML -}}
</div>
{{- end -}}
</div>
{{- else -}}
{{- if .Get "ratio" -}}<style>{{- range $index, $grow := $ratio -}}
.book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
flex-grow: {{ default 1 $grow }};
}
{{- end -}}</style>{{- end -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns")
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{ .Inner | safeHTML -}}
</div>
{{- end -}}

View File

@@ -0,0 +1,14 @@
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"open" (cond .IsNamedParams (.Get "open") (in .Params "open"))
)
) -}}
<details {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}}
<summary>{{ $summary | .Page.RenderString }}</summary>
{{- /* remove whitespaces */ -}}
<div class="markdown-inner">
{{ .Inner | safeHTML -}}
</div></details>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,11 @@
{{- warnf "Hint shortcode is deprecated, use markdown alerts format: '> [!NOTE] ...'" -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-hint" (or (.Get 0) "default"))
)
) -}}
<blockquote {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{ .Inner | safeHTML -}}
</blockquote>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1 @@
{{- .Inner | safeHTML -}}

View File

@@ -0,0 +1 @@
{{- partial "docs/text/i18n" (.Get 0) -}}

View File

@@ -0,0 +1,10 @@
{{- $destination := partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "src")) -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"keep" (slice "id" "class" "tabindex" "alt" "title" "loading")
) -}}
<label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
<img src="{{ $destination | safeURL }}" {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }} />
</label>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,23 @@
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" "book-katex"
)
) -}}
{{- if .Inner -}}
{{- if .Get "display" -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>{{ printf "\\[ %s \\]" .Inner }}</div>
{{- else -}}
<span {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>{{ printf "\\( %s \\)" .Inner }}</span>
{{- end -}}
{{- end -}}
{{- if not (.Page.Store.Get "katex") -}}
{{- /* Include katex only first time */ -}}
<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" />
{{- /* remove whitespaces */ -}}
<script defer src="{{ "katex/katex.min.js" | relURL }}"></script>
{{- with resources.Get "katex.json" | minify -}}
<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body, {{ .Content | safeJS }});"></script>
{{- end -}}
{{- .Page.Store.Set "katex" true -}}
{{- end -}}

View File

@@ -0,0 +1,16 @@
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" "mermaid"
)
) -}}
<pre {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- .Inner | htmlEscape | safeHTML -}}
</pre>
{{- if not (.Page.Store.Get "mermaid") -}}
{{- /* Include mermaid only first time */ -}}
{{- with resources.Get "mermaid.json" | minify -}}
<script src="{{ "mermaid.min.js" | relURL }}" onload="mermaid.initialize({{ .Content | safeJS }})"></script>
{{- end -}}
{{- .Page.Store.Set "mermaid" true -}}
{{- end -}}

View File

@@ -0,0 +1,13 @@
{{- warnf "Section shortcode is deprecated and will be removed" -}}
<dl>
{{ range .Page.Pages }}
<dt>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</dt>
{{ if (in $.Params "summary") -}}
<dd class="markdown-inner">
{{- or .Description .Summary site.Params.description | plainify | htmlUnescape }}
</dd>
{{ end -}}
{{ end }}
</dl>

View File

@@ -0,0 +1,10 @@
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" "book-steps"
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{ .Inner -}}
</div>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,12 @@
{{- $group := printf "tabs-%v" .Parent.Ordinal -}}
{{- $tab := printf "%s-%d" $group .Ordinal -}}
<input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} />
{{- /* remove whitespaces */ -}}
<label for="{{ $tab }}">
{{- .Get 0 -}}
</label>
{{- /* remove whitespaces */ -}}
<div class="book-tabs-content markdown-inner">
{{ .Inner -}}
</div>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,10 @@
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" "book-tabs"
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- .Inner -}}
</div>
{{- /* remove whitespaces */ -}}

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="{{ default .Site.Language.Lang .Site.LanguageCode }}" dir="{{ default "ltr" .Site.Language.LanguageDirection }}">
<head>
{{ partial "docs/html-head" . }}
{{ partial "docs/inject/head" . }}
</head>
<body dir="{{ default "ltr" .Site.Language.LanguageDirection }}" class="book-kind-{{ .Kind }} book-type-{{ .Type }}{{ with .Layout }} book-layout-{{ . }}{{ end }}">
<input type="checkbox" class="hidden toggle" id="menu-control" />
<input type="checkbox" class="hidden toggle" id="toc-control" />
<main class="container flex">
{{ template "menu-container" . }} <!-- Left menu -->
<div class="book-page">
<header class="book-header hidden">
{{ template "header" . }} <!-- Mobile layout header -->
</header>
{{ partial "docs/inject/content-before" . }}
{{ template "main" . }} <!-- Page Content -->
{{ partial "docs/inject/content-after" . }}
<footer class="book-footer">
{{ template "footer" . }} <!-- Footer under page content -->
{{ template "comments" . }} <!-- Comments block -->
{{ partial "docs/inject/footer" . }}
{{ template "copyright" . }} <!-- Copyright block -->
{{ template "clipboard" . }}
</footer>
<label for="menu-control" class="hidden book-menu-overlay"></label>
</div>
{{ template "toc-container" . }} <!-- Table of Contents -->
</main>
{{ partial "docs/inject/body" . }}
</body>
</html>
{{ define "menu-container" }}
<aside class="book-menu">
<div class="book-menu-content">
{{ template "menu" . }}
</div>
</aside>
{{ end }}
{{ define "menu" }}
{{ partial "docs/menu" . }}
{{ end }}
{{ define "header" }}
{{ partial "docs/header" . }}
{{ if partial "docs/toc-show" . }}
<aside class="hidden">
{{ template "toc" . }}
</aside>
{{ end }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/footer" . }}
{{ end }}
{{ define "clipboard" }}
<!-- Clipboard -->
{{ with resources.Get "clipboard.js" | resources.Minify }}
<script>{{ .Content | safeJS }}</script>
{{ end }}
{{ end }}
{{ define "copyright" }}
{{ if .Site.Copyright }}
<div class="book-copyright flex justify-center">
{{ partial "docs/copyright" . }}
</div>
{{ end }}
{{ end }}
{{ define "comments" }}
{{ if and .Content (default true (default .Site.Params.BookComments .Params.BookComments)) }}
<div class="book-comments">
{{- partial "docs/comments" . -}}
</div>
{{ end }}
{{ end }}
{{ define "main" }}
<article class="markdown book-article">
{{- .Content -}}
</article>
{{ end }}
{{ define "toc-container" }}
{{ if partial "docs/toc-show" . }}
<aside class="book-toc">
<div class="book-toc-content">
{{ template "toc" . }}
</div>
</aside>
{{ end }}
{{ end }}
{{ define "toc" }}
{{ partial "docs/toc" . }}
{{ end }}

View File

@@ -0,0 +1,15 @@
{{ define "menu-container" }}
<!-- -->
{{ end }}
{{ define "toc-container" }}
<!-- -->
{{ end }}
{{ define "footer" }}
<!-- -->
{{ end }}
{{ define "header" }}
<nav>
{{ partial "docs/menu-hugo" (dict "Page" .Page "Menu" .Site.Menus.home) }}
</nav>
{{ end }}

View File

@@ -0,0 +1 @@
{{ define "dummy" }}{{ end }}

View File

@@ -0,0 +1 @@
<script async defer data-domain="{{ .Site.Params.plausibleDomain }}" src="https://plausible.io/js/plausible.js"></script>

View File

@@ -0,0 +1,39 @@
{{ define "main" }}
{{ range sort .Paginator.Pages }}
<article class="book-post markdown">
<h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</h2>
<div class="book-post-container flex gap">
<div>
{{ partial "docs/post-meta" . }}
<div class="book-post-content markdown-inner">
{{- .Summary | truncate 256 -}}
</div>
</div>
{{- $thumbnail := default "thumbnail.*" .Params.BookPostThumbnail -}}
{{- with or (.Resources.GetMatch $thumbnail) (resources.GetMatch $thumbnail) -}}
<div class="book-post-thumbnail">
<img src="{{ .RelPermalink }}" alt="{{ partial "docs/text/i18n" "Thumbnail" }}" />
</div>
{{- end -}}
</div>
</article>
{{ end }}
{{ end }}
{{ define "toc-container" }}
<aside class="book-toc">
<div class="book-toc-content">
{{ template "toc" . }}
</div>
</aside>
{{ end }}
{{ define "toc" }}
{{ partial "docs/taxonomy" . }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/pagination.html" . }}
{{ end }}

View File

@@ -0,0 +1,19 @@
{{ define "main" }}
<article class="markdown book-post">
<h1>
{{ partial "docs/title" . }}
</h1>
{{ partial "docs/post-meta" . }}
<div class="book-post-content markdown-inner">
{{- .Content -}}
</div>
</article>
{{ end }}
{{ define "toc" }}
{{ partial "docs/toc" . }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/post-prev-next" . }}
{{ end }}

View File

@@ -0,0 +1 @@
{{ define "dummy" }}{{ end }}

View File

@@ -0,0 +1,27 @@
{{ define "main" }}
{{ range sort .Paginator.Pages }}
<article class="markdown book-post">
<h2>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</h2>
{{ partial "docs/post-meta" . }}
<div class="book-post-content">
{{- .Summary -}}
</div>
</article>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
{{ define "toc-container" }}
<aside class="book-toc">
<div class="book-toc-content">
{{ template "toc" . }}
</div>
</aside>
{{ end }}
{{ define "toc" }}
{{ partial "docs/taxonomy" . }}
{{ end }}