hugo-book
This commit is contained in:
8
themes/hugo-book/layouts/partials/docs/brand.html
Normal file
8
themes/hugo-book/layouts/partials/docs/brand.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<h2 class="book-brand">
|
||||
<a class="flex align-center" href="{{ cond (not .Site.Home.File) .Sites.First.Home.RelPermalink .Site.Home.RelPermalink }}">
|
||||
{{- with .Site.Params.BookLogo -}}
|
||||
<img src="{{ . | relURL }}" alt="Logo" />
|
||||
{{- end -}}
|
||||
<span>{{ .Site.Title }}</span>
|
||||
</a>
|
||||
</h2>
|
||||
2
themes/hugo-book/layouts/partials/docs/comments.html
Normal file
2
themes/hugo-book/layouts/partials/docs/comments.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<!-- This partial can be replaced to support other commenting engines -->
|
||||
{{ template "_internal/disqus.html" . }}
|
||||
6
themes/hugo-book/layouts/partials/docs/date.html
Normal file
6
themes/hugo-book/layouts/partials/docs/date.html
Normal 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 (.Date.Format $format) -}}
|
||||
28
themes/hugo-book/layouts/partials/docs/footer.html
Normal file
28
themes/hugo-book/layouts/partials/docs/footer.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<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) -}}
|
||||
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
|
||||
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
|
||||
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
|
||||
<span>{{ $date }}</span>
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
|
||||
<div>
|
||||
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ .Site.Params.contentDir | default "content" }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
|
||||
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="Edit" />
|
||||
<span>{{ i18n "Edit this page" }}</span>
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
|
||||
{{ $script := resources.Get "clipboard.js" | resources.Minify }}
|
||||
{{ with $script.Content }}
|
||||
<script>{{ . | safeJS }}</script>
|
||||
{{ end }}
|
||||
13
themes/hugo-book/layouts/partials/docs/header.html
Normal file
13
themes/hugo-book/layouts/partials/docs/header.html
Normal file
@@ -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>
|
||||
|
||||
<strong>{{ partial "docs/title" . }}</strong>
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1 @@
|
||||
{{ partial "docs/title" . }} | {{ .Site.Title -}}
|
||||
55
themes/hugo-book/layouts/partials/docs/html-head.html
Normal file
55
themes/hugo-book/layouts/partials/docs/html-head.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<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" content="#FFFFFF">
|
||||
<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>
|
||||
|
||||
{{- $manifest := resources.Get "manifest.json" | resources.ExecuteAsTemplate "manifest.json" . }}
|
||||
<link rel="manifest" href="{{ $manifest.RelPermalink }}">
|
||||
<link rel="icon" href="{{ "favicon.png" | relURL }}" type="image/x-icon">
|
||||
|
||||
{{- range .Translations }}
|
||||
<link rel="alternate" hreflang="{{ default .Language.Lang .Site.LanguageCode }}" 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" . | resources.ToCSS | 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="{{ "flexsearch.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 -}}
|
||||
33
themes/hugo-book/layouts/partials/docs/languages.html
Normal file
33
themes/hugo-book/layouts/partials/docs/languages.html
Normal file
@@ -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="{{ .Permalink }}">
|
||||
{{ .Language.LanguageName }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}{{ end }}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
5
themes/hugo-book/layouts/partials/docs/menu-bundle.html
Normal file
5
themes/hugo-book/layouts/partials/docs/menu-bundle.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{ with .Site.GetPage .Site.Params.BookMenuBundle }}
|
||||
{{- $href := printf "href=\"%s\"" $.RelPermalink -}}
|
||||
{{- replace .Content $href (print $href "class=active") | safeHTML -}}
|
||||
{{- warnf "Bundle menu mode is deprecated and will be removed" -}}
|
||||
{{ end }}
|
||||
49
themes/hugo-book/layouts/partials/docs/menu-filetree.html
Normal file
49
themes/hugo-book/layouts/partials/docs/menu-filetree.html
Normal file
@@ -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 }}
|
||||
28
themes/hugo-book/layouts/partials/docs/menu-hugo.html
Normal file
28
themes/hugo-book/layouts/partials/docs/menu-hugo.html
Normal file
@@ -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 }}
|
||||
25
themes/hugo-book/layouts/partials/docs/menu.html
Normal file
25
themes/hugo-book/layouts/partials/docs/menu.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<nav>
|
||||
{{ partial "docs/brand" . }}
|
||||
{{ partial "docs/search" . }}
|
||||
{{ if .Site.IsMultiLingual }}
|
||||
{{ partial "docs/languages" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "docs/inject/menu-before" . }}
|
||||
{{ partial "docs/menu-hugo" .Site.Menus.before }}
|
||||
|
||||
{{ if .Site.Params.BookMenuBundle }}
|
||||
{{ partial "docs/menu-bundle" . }}
|
||||
{{ else }}
|
||||
{{ partial "docs/menu-filetree" . }}
|
||||
{{ end }}
|
||||
|
||||
{{ 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 }}
|
||||
23
themes/hugo-book/layouts/partials/docs/post-meta.html
Normal file
23
themes/hugo-book/layouts/partials/docs/post-meta.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{{ with .Date }}
|
||||
<h5>{{ partial "docs/date" (dict "Date" . "Format" $.Site.Params.BookDateFormat) }}</h5>
|
||||
{{ end }}
|
||||
|
||||
{{ range $taxonomy, $_ := .Site.Taxonomies }}
|
||||
{{ with $terms := $.GetTerms $taxonomy }}
|
||||
<div>
|
||||
{{ range $n, $term := $terms }}{{ if $n }}, {{ end }}
|
||||
<a href="{{ $term.RelPermalink }}">{{ $term.Title }}</a>
|
||||
{{- end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.image }}
|
||||
<p>
|
||||
{{ with .Resources.GetMatch .Params.image }}
|
||||
<img src={{ .RelPermalink }} />
|
||||
{{ else }}
|
||||
<img src={{ .Params.image | relURL }} />
|
||||
{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
7
themes/hugo-book/layouts/partials/docs/search.html
Normal file
7
themes/hugo-book/layouts/partials/docs/search.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{ if default true .Site.Params.BookSearch }}
|
||||
<div class="book-search">
|
||||
<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>
|
||||
{{ end }}
|
||||
19
themes/hugo-book/layouts/partials/docs/taxonomy.html
Normal file
19
themes/hugo-book/layouts/partials/docs/taxonomy.html
Normal file
@@ -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>
|
||||
17
themes/hugo-book/layouts/partials/docs/title.html
Normal file
17
themes/hugo-book/layouts/partials/docs/title.html
Normal 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 }}
|
||||
3
themes/hugo-book/layouts/partials/docs/toc.html
Normal file
3
themes/hugo-book/layouts/partials/docs/toc.html
Normal file
@@ -0,0 +1,3 @@
|
||||
{{ partial "docs/inject/toc-before" . }}
|
||||
{{ .TableOfContents }}
|
||||
{{ partial "docs/inject/toc-after" . }}
|
||||
Reference in New Issue
Block a user