diff options
Diffstat (limited to '')
50 files changed, 639 insertions, 0 deletions
diff --git a/themes/hugo-book/layouts/404.html b/themes/hugo-book/layouts/404.html new file mode 100644 index 0000000..909430e --- /dev/null +++ b/themes/hugo-book/layouts/404.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<html lang="{{ .Site.Language.Lang }}"> + + <head> + {{ partial "docs/html-head" . }} + {{ partial "docs/inject/head" . }} + + <style> + .not-found { + text-align: center; + } + .not-found h1 { + margin: .25em 0 0 0; + opacity: .25; + font-size: 40vmin; + } + </style> + </head> + + <body> + <main class="flex justify-center not-found"> + <div> + <h1>404</h1> + <h2>Page Not Found</h2> + <h3> + <a href="{{ .Site.Home.RelPermalink }}">{{ .Site.Title }}</a> + </h3> + </div> + </main> + + {{ partial "docs/inject/body" . }} + </body> + + </html> diff --git a/themes/hugo-book/layouts/_default/_markup/render-heading.html b/themes/hugo-book/layouts/_default/_markup/render-heading.html new file mode 100644 index 0000000..5439d20 --- /dev/null +++ b/themes/hugo-book/layouts/_default/_markup/render-heading.html @@ -0,0 +1,4 @@ +<h{{ .Level }} id="{{ .Anchor | safeURL }}"> + {{ .Text | safeHTML }} + <a class="anchor" href="#{{ .Anchor | safeURL }}">#</a> +</h{{ .Level }}> diff --git a/themes/hugo-book/layouts/_default/_markup/render-image.html b/themes/hugo-book/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..148cbaf --- /dev/null +++ b/themes/hugo-book/layouts/_default/_markup/render-image.html @@ -0,0 +1,19 @@ +{{- if .Page.Site.Params.BookPortableLinks -}} + {{- template "portable-image" . -}} +{{- else -}} + <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/> +{{- end -}} + +{{- define "portable-image" -}} + {{- $isRemote := or (in .Destination "://") (strings.HasPrefix .Destination "//") }} + {{- if not $isRemote }} + {{- $path := print .Page.File.Dir .Destination }} + {{- if strings.HasPrefix .Destination "/" }} + {{- $path = print "/static" .Destination }} + {{- end }} + {{- if not (fileExists $path) }} + {{- warnf "Image '%s' not found in '%s'" .Destination .Page.File }} + {{- end }} + {{- end }} + <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/> +{{- end -}} diff --git a/themes/hugo-book/layouts/_default/_markup/render-link.html b/themes/hugo-book/layouts/_default/_markup/render-link.html new file mode 100644 index 0000000..288d81c --- /dev/null +++ b/themes/hugo-book/layouts/_default/_markup/render-link.html @@ -0,0 +1,29 @@ +{{- if .Page.Site.Params.BookPortableLinks -}} + {{- template "portable-link" . -}} +{{- else -}} + <a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a> +{{- end -}} + +{{- define "portable-link" -}} + {{- $destination := .Destination }} + {{- $isRemote := or (in .Destination ":") (strings.HasPrefix .Destination "//") }} + {{- $isFragment := strings.HasPrefix .Destination "#" }} + {{- if and (not $isRemote) (not $isFragment) }} + {{- $url := urls.Parse .Destination }} + {{- $path := strings.TrimSuffix "/_index.md" $url.Path }} + {{- $path = strings.TrimSuffix "/_index" $path }} + {{- $path = strings.TrimSuffix ".md" $path }} + {{- $page := .Page.GetPage $path }} + {{- if $page }} + {{- $destination = $page.RelPermalink }} + {{- if $url.Fragment }} + {{- $destination = print $destination "#" $url.Fragment }} + {{- end }} + {{- else if fileExists (print .Page.File.Dir .Destination) }} + <!-- Nothing --> + {{- else -}} + {{- warnf "Page '%s' not found in '%s'" .Destination .Page.File }} + {{- end }} + {{- end }} + <a href="{{ $destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a> +{{- end -}} diff --git a/themes/hugo-book/layouts/_default/baseof.html b/themes/hugo-book/layouts/_default/baseof.html new file mode 100644 index 0000000..a6c4c07 --- /dev/null +++ b/themes/hugo-book/layouts/_default/baseof.html @@ -0,0 +1,83 @@ +<!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 }}"> + <input type="checkbox" class="hidden toggle" id="menu-control" /> + <input type="checkbox" class="hidden toggle" id="toc-control" /> + <main class="container flex"> + <aside class="book-menu"> + <div class="book-menu-content"> + {{ template "menu" . }} <!-- Left menu Content --> + </div> + </aside> + + <div class="book-page"> + <header class="book-header"> + {{ 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 --> + {{ partial "docs/inject/footer" . }} + </footer> + + {{ template "comments" . }} <!-- Comments block --> + + <label for="menu-control" class="hidden book-menu-overlay"></label> + </div> + + {{ if default true (default .Site.Params.BookToC .Params.BookToC) }} + <aside class="book-toc"> + <div class="book-toc-content"> + {{ template "toc" . }} <!-- Table of Contents --> + </div> + </aside> + {{ end }} + </main> + + {{ partial "docs/inject/body" . }} +</body> +</html> + +{{ define "menu" }} + {{ partial "docs/menu" . }} +{{ end }} + +{{ define "header" }} + {{ partial "docs/header" . }} + + {{ if default true (default .Site.Params.BookToC .Params.BookToC) }} + <aside class="hidden clearfix"> + {{ template "toc" . }} + </aside> + {{ end }} +{{ end }} + +{{ define "footer" }} + {{ partial "docs/footer" . }} +{{ 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" }} + {{ partial "docs/toc" . }} +{{ end }} diff --git a/themes/hugo-book/layouts/_default/list.html b/themes/hugo-book/layouts/_default/list.html new file mode 100644 index 0000000..0dc8b68 --- /dev/null +++ b/themes/hugo-book/layouts/_default/list.html @@ -0,0 +1 @@ +{{ define "dummy" }}{{ end }} diff --git a/themes/hugo-book/layouts/_default/single.html b/themes/hugo-book/layouts/_default/single.html new file mode 100644 index 0000000..0dc8b68 --- /dev/null +++ b/themes/hugo-book/layouts/_default/single.html @@ -0,0 +1 @@ +{{ define "dummy" }}{{ end }} diff --git a/themes/hugo-book/layouts/partials/docs/brand.html b/themes/hugo-book/layouts/partials/docs/brand.html new file mode 100644 index 0000000..fa7f415 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/brand.html @@ -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="Logo" class="book-icon" /> + {{- end -}} + <span>{{ .Site.Title }}</span> + </a> +</h2> diff --git a/themes/hugo-book/layouts/partials/docs/comments.html b/themes/hugo-book/layouts/partials/docs/comments.html new file mode 100644 index 0000000..59c5f22 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/comments.html @@ -0,0 +1,2 @@ +<!-- This partial can be replaced to support other commenting engines --> +{{ template "_internal/disqus.html" . }} diff --git a/themes/hugo-book/layouts/partials/docs/date.html b/themes/hugo-book/layouts/partials/docs/date.html new file mode 100644 index 0000000..8c75361 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/date.html @@ -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) -}} diff --git a/themes/hugo-book/layouts/partials/docs/footer.html b/themes/hugo-book/layouts/partials/docs/footer.html new file mode 100644 index 0000000..77e96d8 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/footer.html @@ -0,0 +1,27 @@ +<div class="flex flex-wrap justify-between"> + +{{ if and .GitInfo .Site.Params.BookRepo }} + <div> + {{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}} + <a class="flex align-center" href="{{ partial "docs/links/commit" . }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener"> + <img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="" /> + <span>{{ $date }}</span> + </a> + </div> +{{ end }} + +{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }} + <div> + <a class="flex align-center" href="{{ partial "docs/links/edit" . }}" target="_blank" rel="noopener"> + <img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="" /> + <span>{{ i18n "Edit this page" }}</span> + </a> + </div> +{{ end }} + +</div> + +{{ $script := resources.Get "clipboard.js" | resources.Minify }} +{{ with $script.Content }} + <script>{{ . | safeJS }}</script> +{{ end }} diff --git a/themes/hugo-book/layouts/partials/docs/header.html b/themes/hugo-book/layouts/partials/docs/header.html new file mode 100644 index 0000000..646b8ff --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/header.html @@ -0,0 +1,13 @@ +<div class="flex align-center justify-between"> + <label for="menu-control"> + <img src="{{ "svg/menu.svg" | relURL }}" class="book-icon" alt="Menu" /> + </label> + + <h3>{{ partial "docs/title" . }}</h3> + + <label for="toc-control"> + {{ if default true (default .Site.Params.BookToC .Params.BookToC) }} + <img src="{{ "svg/toc.svg" | relURL }}" class="book-icon" alt="Table of Contents" /> + {{ end }} + </label> +</div> diff --git a/themes/hugo-book/layouts/partials/docs/html-head-favicon.html b/themes/hugo-book/layouts/partials/docs/html-head-favicon.html new file mode 100644 index 0000000..8278050 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/html-head-favicon.html @@ -0,0 +1 @@ +<link rel="icon" href="{{ .Site.Params.BookFavicon | default "favicon.png" | relURL }}" >
\ No newline at end of file diff --git a/themes/hugo-book/layouts/partials/docs/html-head-title.html b/themes/hugo-book/layouts/partials/docs/html-head-title.html new file mode 100644 index 0000000..49a109d --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/html-head-title.html @@ -0,0 +1 @@ +{{ partial "docs/title" . }} | {{ .Site.Title -}} diff --git a/themes/hugo-book/layouts/partials/docs/html-head.html b/themes/hugo-book/layouts/partials/docs/html-head.html new file mode 100644 index 0000000..6a6d0ec --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/html-head.html @@ -0,0 +1,56 @@ +<meta charset="UTF-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<meta name="description" content="{{ default .Summary .Description }}"> +<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 -}} + +{{- template "_internal/opengraph.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="{{ $styles.RelPermalink }}" {{ template "integrity" $styles }}> +{{- 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="{{ $searchJS.RelPermalink }}" {{ template "integrity" $searchJS }}></script> +{{ end -}} + +{{- 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 -}} + +{{- template "_internal/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 -}} + +{{ "<!--" | safeHTML }} +Made with Book Theme +https://github.com/alex-shpak/hugo-book +{{ "-->" | safeHTML }} + +{{- define "integrity" -}} + {{- if (urls.Parse .Permalink).Host -}} + integrity="{{ .Data.Integrity }}" crossorigin="anonymous" + {{- end -}} +{{- end -}} diff --git a/themes/hugo-book/layouts/partials/docs/inject/body.html b/themes/hugo-book/layouts/partials/docs/inject/body.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/body.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/content-after.html b/themes/hugo-book/layouts/partials/docs/inject/content-after.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/content-after.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/content-before.html b/themes/hugo-book/layouts/partials/docs/inject/content-before.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/content-before.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/footer.html b/themes/hugo-book/layouts/partials/docs/inject/footer.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/footer.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/head.html b/themes/hugo-book/layouts/partials/docs/inject/head.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/head.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/menu-after.html b/themes/hugo-book/layouts/partials/docs/inject/menu-after.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/menu-after.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/menu-before.html b/themes/hugo-book/layouts/partials/docs/inject/menu-before.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/menu-before.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/toc-after.html b/themes/hugo-book/layouts/partials/docs/inject/toc-after.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/toc-after.html diff --git a/themes/hugo-book/layouts/partials/docs/inject/toc-before.html b/themes/hugo-book/layouts/partials/docs/inject/toc-before.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/inject/toc-before.html diff --git a/themes/hugo-book/layouts/partials/docs/languages.html b/themes/hugo-book/layouts/partials/docs/languages.html new file mode 100644 index 0000000..51aabdd --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/languages.html @@ -0,0 +1,33 @@ +<!-- Merge home and current page translations --> +{{ $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 justify-between"> + <a role="button" class="flex align-center"> + <img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" /> + {{ $.Site.Language.LanguageName }} + </a> + </label> + + <ul> + {{ range .Site.Languages }}{{ with index $translations .Lang }} + <li> + <a href="{{ cond hugo.IsMultihost .Permalink .RelPermalink }}"> + {{ .Language.LanguageName }} + </a> + </li> + {{ end }}{{ end }} + </ul> + </li> +</ul> diff --git a/themes/hugo-book/layouts/partials/docs/links/commit.html b/themes/hugo-book/layouts/partials/docs/links/commit.html new file mode 100644 index 0000000..8ab9334 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/links/commit.html @@ -0,0 +1,2 @@ +{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}} +{{- .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash -}}
\ No newline at end of file diff --git a/themes/hugo-book/layouts/partials/docs/links/edit.html b/themes/hugo-book/layouts/partials/docs/links/edit.html new file mode 100644 index 0000000..920affa --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/links/edit.html @@ -0,0 +1,2 @@ +{{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}} +{{- .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}{{ ($bookFilePath) -}}
\ No newline at end of file diff --git a/themes/hugo-book/layouts/partials/docs/menu-filetree.html b/themes/hugo-book/layouts/partials/docs/menu-filetree.html new file mode 100644 index 0000000..1494588 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/menu-filetree.html @@ -0,0 +1,49 @@ +{{ $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 justify-between"> + <a {{ if .Page.Content }}href="{{ .Page.RelPermalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}"> + {{- partial "docs/title" .Page -}} + </a> + </label> + {{ else if .Page.Params.BookHref }} + <a href="{{ .Page.Params.BookHref }}" class="{{ if $current }}active{{ end }}" target="_blank" rel="noopener"> + {{- partial "docs/title" .Page -}} + </a> + {{ else if .Page.Content }} + <a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}"> + {{- partial "docs/title" .Page -}} + </a> + {{ else }} + <span>{{- partial "docs/title" .Page -}}</span> + {{ end }} +{{ end }} diff --git a/themes/hugo-book/layouts/partials/docs/menu-hugo.html b/themes/hugo-book/layouts/partials/docs/menu-hugo.html new file mode 100644 index 0000000..5f01be0 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/menu-hugo.html @@ -0,0 +1,28 @@ +<!-- + This is template for hugo menus, accepts MenuEntity as context + https://gohugo.io/variables/menus/ +--> +{{ if . }} + {{ template "book-menu-hugo" . }} +{{ end }} + +{{ define "book-menu-hugo" }} +<ul> + {{ range . }} + <li> + <a href="{{ .URL }}" {{ with .Params.class }}class="{{ . }}"{{ end }} {{ if not .Page }}target="_blank" rel="noopener"{{ end }}> + {{- .Pre -}} + {{ with .Page }} + {{ partial "docs/title" .Page }} + {{ else }} + {{ .Name }} + {{ end }} + {{- .Post -}} + </a> + {{- with .Children }} + {{ template "book-menu-hugo" . }} + {{- end }} + </li> + {{ end }} +</ul> +{{ end }} diff --git a/themes/hugo-book/layouts/partials/docs/menu.html b/themes/hugo-book/layouts/partials/docs/menu.html new file mode 100644 index 0000000..dbb2e49 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/menu.html @@ -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" .Site.Menus.before }} + +{{ partial "docs/menu-filetree" . }} + +{{ partial "docs/menu-hugo" .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 }} diff --git a/themes/hugo-book/layouts/partials/docs/post-meta.html b/themes/hugo-book/layouts/partials/docs/post-meta.html new file mode 100644 index 0000000..457e2c0 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/post-meta.html @@ -0,0 +1,16 @@ +{{ with .Date }} + <div class="flex align-center text-small book-post-date"> + <img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon " alt="" /> + <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 }} diff --git a/themes/hugo-book/layouts/partials/docs/search.html b/themes/hugo-book/layouts/partials/docs/search.html new file mode 100644 index 0000000..937f595 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/search.html @@ -0,0 +1,8 @@ +{{ if default true .Site.Params.BookSearch }} +<div class="book-search hidden"> + <input type="text" id="book-search-input" placeholder="{{ i18n "Search" }}" aria-label="{{ i18n "Search" }}" 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 }} diff --git a/themes/hugo-book/layouts/partials/docs/taxonomy.html b/themes/hugo-book/layouts/partials/docs/taxonomy.html new file mode 100644 index 0000000..63ef315 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/taxonomy.html @@ -0,0 +1,19 @@ +<nav> + <ul> + {{ range $term, $_ := .Site.Taxonomies }} + {{ with $.Site.GetPage (printf "/%s" $term | urlize) }} + <li class="book-section-flat"> + <strong>{{ .Title | title }}</strong> + <ul> + {{ range .Pages }} + <li class="flex justify-between"> + <a href="{{ .RelPermalink }}">{{ .Title }}</a> + <span>{{ len .Pages }}</span> + </li> + {{ end }} + </ul> + </li> + {{ end }} + {{ end }} + </ul> +</nav> diff --git a/themes/hugo-book/layouts/partials/docs/title.html b/themes/hugo-book/layouts/partials/docs/title.html new file mode 100644 index 0000000..83df5b6 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/title.html @@ -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 }} diff --git a/themes/hugo-book/layouts/partials/docs/toc.html b/themes/hugo-book/layouts/partials/docs/toc.html new file mode 100644 index 0000000..64697a4 --- /dev/null +++ b/themes/hugo-book/layouts/partials/docs/toc.html @@ -0,0 +1,3 @@ +{{ partial "docs/inject/toc-before" . }} +{{ .TableOfContents }} +{{ partial "docs/inject/toc-after" . }} diff --git a/themes/hugo-book/layouts/posts/list.html b/themes/hugo-book/layouts/posts/list.html new file mode 100644 index 0000000..aff32f5 --- /dev/null +++ b/themes/hugo-book/layouts/posts/list.html @@ -0,0 +1,22 @@ +{{ define "main" }} + {{ range sort .Paginator.Pages }} + <article class="markdown book-post"> + <h2> + <a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a> + </h2> + {{ partial "docs/post-meta" . }} + <div class="book-post-content"> + {{- .Summary -}} + {{ if .Truncated }} + <a href="{{ .RelPermalink }}">...</a> + {{ end }} + </div> + </article> + {{ end }} + + {{ template "_internal/pagination.html" . }} +{{ end }} + +{{ define "toc" }} + {{ partial "docs/taxonomy" . }} +{{ end }} diff --git a/themes/hugo-book/layouts/posts/single.html b/themes/hugo-book/layouts/posts/single.html new file mode 100644 index 0000000..cebdd11 --- /dev/null +++ b/themes/hugo-book/layouts/posts/single.html @@ -0,0 +1,15 @@ +{{ define "main" }} +<article class="markdown book-post"> + <h1> + {{ partial "docs/title.html" . }} + </h1> + {{ partial "docs/post-meta" . }} + <div class="book-post-content"> + {{- .Content -}} + </div> +</article> +{{ end }} + +{{ define "toc" }} + {{ partial "docs/toc" . }} +{{ end }} diff --git a/themes/hugo-book/layouts/shortcodes/button.html b/themes/hugo-book/layouts/shortcodes/button.html new file mode 100644 index 0000000..efae3e0 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/button.html @@ -0,0 +1,12 @@ +{{- $ref := "" }} +{{- $target := "" -}} +{{- with .Get "href" -}} + {{- $ref = . -}} + {{- $target = "_blank" -}} +{{- end -}} +{{- with .Get "relref" -}} + {{- $ref = relref $ . -}} +{{- end -}} +<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}"> + {{- .InnerDeindent -}} +</a> diff --git a/themes/hugo-book/layouts/shortcodes/columns.html b/themes/hugo-book/layouts/shortcodes/columns.html new file mode 100644 index 0000000..bb01da9 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/columns.html @@ -0,0 +1,9 @@ +{{- $ratio := (split (.Get "ratio") ":") -}} +<div class="book-columns flex flex-wrap{{ with .Get "class" }} {{ . }}{{ end }}"> +{{ 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> diff --git a/themes/hugo-book/layouts/shortcodes/details.html b/themes/hugo-book/layouts/shortcodes/details.html new file mode 100644 index 0000000..a80209b --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/details.html @@ -0,0 +1,7 @@ +<details {{ if or (.Get "open") (in .Params "open") }}open{{ end }}> + {{- $summary := cond .IsNamedParams (.Get "title") (.Get 0) -}} + <summary>{{ $summary }}</summary> + <div class="markdown-inner"> + {{ .InnerDeindent | safeHTML }} + </div> +</details> diff --git a/themes/hugo-book/layouts/shortcodes/hint.html b/themes/hugo-book/layouts/shortcodes/hint.html new file mode 100644 index 0000000..95e4f83 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/hint.html @@ -0,0 +1,3 @@ +<blockquote class="book-hint {{ .Get 0 }}"> + {{ .Inner | safeHTML }} +</blockquote> diff --git a/themes/hugo-book/layouts/shortcodes/html.html b/themes/hugo-book/layouts/shortcodes/html.html new file mode 100644 index 0000000..b447d45 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/html.html @@ -0,0 +1 @@ +{{- .Inner | safeHTML -}}
\ No newline at end of file diff --git a/themes/hugo-book/layouts/shortcodes/i18n.html b/themes/hugo-book/layouts/shortcodes/i18n.html new file mode 100644 index 0000000..b65f70a --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/i18n.html @@ -0,0 +1,2 @@ +{{- $content := .Get 0 -}} +{{- default $content (i18n $content) -}}
\ No newline at end of file diff --git a/themes/hugo-book/layouts/shortcodes/katex.html b/themes/hugo-book/layouts/shortcodes/katex.html new file mode 100644 index 0000000..4eafc35 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/katex.html @@ -0,0 +1,13 @@ +{{- if not (.Page.Scratch.Get "katex") -}} +<!-- Include katex only first time --> +<link rel="stylesheet" href="{{ "katex/katex.min.css" | relURL }}" /> +<script defer src="{{ "katex/katex.min.js" | relURL }}"></script> +<script defer src="{{ "katex/auto-render.min.js" | relURL }}" onload="renderMathInElement(document.body);"></script> +{{- .Page.Scratch.Set "katex" true -}} +{{- end -}} + +<span {{- with .Get "class" }} class="{{ . }}"{{ end }}> + {{ with .Get "display" }}\[{{else}}\({{end}} + {{- .InnerDeindent -}} + {{ with .Get "display" }}\]{{else}}\){{end}} +</span> diff --git a/themes/hugo-book/layouts/shortcodes/mermaid.html b/themes/hugo-book/layouts/shortcodes/mermaid.html new file mode 100644 index 0000000..07a3bfc --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/mermaid.html @@ -0,0 +1,12 @@ +{{ if not (.Page.Scratch.Get "mermaid") }} +<!-- Include mermaid only first time --> +<script src="{{ "mermaid.min.js" | relURL }}"></script> +{{ with resources.Get "mermaid.json" }} + <script>mermaid.initialize({{ .Content | safeJS }})</script> +{{ end }} +{{ .Page.Scratch.Set "mermaid" true }} +{{ end }} + +<pre class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}"> + {{- .Inner -}} +</pre> diff --git a/themes/hugo-book/layouts/shortcodes/section.html b/themes/hugo-book/layouts/shortcodes/section.html new file mode 100644 index 0000000..b700ec4 --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/section.html @@ -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"> + {{ default .Summary .Description }} + </dd> + {{ end -}} +{{ end }} +</dl> diff --git a/themes/hugo-book/layouts/shortcodes/tab.html b/themes/hugo-book/layouts/shortcodes/tab.html new file mode 100644 index 0000000..b5a753d --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/tab.html @@ -0,0 +1,9 @@ +{{- $group := printf "tabs-%v" (default .Parent.Ordinal (.Parent.Get 0)) -}} +{{- $tab := printf "%s-%d" $group .Ordinal }} +<input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} /> +<label for="{{ $tab }}"> + {{- .Get 0 -}} +</label> +<div class="book-tabs-content markdown-inner"> + {{- .Inner -}} +</div> diff --git a/themes/hugo-book/layouts/shortcodes/tabs.html b/themes/hugo-book/layouts/shortcodes/tabs.html new file mode 100644 index 0000000..fecbbeb --- /dev/null +++ b/themes/hugo-book/layouts/shortcodes/tabs.html @@ -0,0 +1,3 @@ +<div class="book-tabs"> +{{ .Inner }} +</div> diff --git a/themes/hugo-book/layouts/taxonomy/list.html b/themes/hugo-book/layouts/taxonomy/list.html new file mode 100644 index 0000000..1d3e763 --- /dev/null +++ b/themes/hugo-book/layouts/taxonomy/list.html @@ -0,0 +1,13 @@ +{{ define "main" }} +<article class="markdown book-post"> + <h1>{{ .Title | title }}</h1> + {{ $taxonomies := index .Site.Taxonomies .Page.Type }} + {{ range $taxonomies }} + <div><a href="{{ .Page.Permalink }}">{{ .Page.Title }} <sup>{{ .Count }}</sup></a></div> + {{ end }} +</article> +{{ end }} + +{{ define "toc" }} + {{ partial "docs/taxonomy" . }} +{{ end }} diff --git a/themes/hugo-book/layouts/taxonomy/taxonomy.html b/themes/hugo-book/layouts/taxonomy/taxonomy.html new file mode 100644 index 0000000..badf0f6 --- /dev/null +++ b/themes/hugo-book/layouts/taxonomy/taxonomy.html @@ -0,0 +1,22 @@ +{{ define "main" }} + {{ range sort .Paginator.Pages }} + <article class="markdown book-post"> + <h2> + <a href="{{ .RelPermalink }}">{{ partial "docs/title.html" . }}</a> + </h2> + {{ partial "docs/post-meta" . }} + <p> + {{- .Summary -}} + {{ if .Truncated }} + <a href="{{ .RelPermalink }}">...</a> + {{ end }} + </p> + </article> + {{ end }} + + {{ template "_internal/pagination.html" . }} +{{ end }} + +{{ define "toc" }} + {{ partial "docs/taxonomy" . }} +{{ end }} |
