Compare commits

..

23 Commits

Author SHA1 Message Date
Alex Shpak 7b5d299b7b Rewrite prev-next with enw lang. selector 2021-08-30 14:13:46 +02:00
Alex Shpak 26de844a19 #343, #165: Move lang selector to left menu 2021-08-18 11:12:58 +02:00
Alex Shpak 50147be131
Update README.md 2021-07-25 22:44:14 +02:00
Alex Shpak deb00bcad2
Update theme.toml 2021-07-25 22:41:58 +02:00
逊狼 92d97049cf
issues 362 (#364)
* 🐞 fix issues 352

Solve this problem:
https://github.com/alex-shpak/hugo-book/issues/352

The Reason:
https://github.com/gohugoio/hugo/issues/8688

* fix issues 362

https://github.com/alex-shpak/hugo-book/issues/362

* Revert "🐞 fix issues 352"

This reverts commit 58f8935d1e2348d7c9aa03ca2fac8049f486ad3d.

* Revert "Revert "🐞 fix issues 352""

This reverts commit fa0d46ccf56f435a628af17798d36616a5c23d86.

* fix issues 362

* Update columns.html

* Revert "Revert "Revert "🐞 fix issues 352"""

This reverts commit 79777a9e846334b6043048b156d972212802931c.

Co-authored-by: Alex Shpak <alex-shpak@users.noreply.github.com>
2021-07-20 16:20:43 +02:00
Marco Guerrini c4d69635af
Added italian translation (#356) 2021-07-01 11:26:02 +02:00
xhdix e939f40314
Add Farsi with support for search RTL texts (#350)
Farsi/Parsi/Persian
2021-06-21 21:11:36 +02:00
xhdix 0d2ed5586e
Change collapsed icon in menu for RTL pages (#354) 2021-06-21 20:18:14 +02:00
xhdix 379e311d7e
Fix menu not working in RTL menu (#349) 2021-06-08 10:08:46 +02:00
Nikolay Raspopov 4540d66e3b
Document removal of internal hugo templates (#345) 2021-05-27 09:11:13 +02:00
Alex Shpak fde10f1319 #285, skip integrity attribute if site is built without hostname 2021-05-21 00:50:38 +02:00
Alex Shpak f6e8d1b693 Add deprecation notice for menu bundle 2021-05-21 00:46:53 +02:00
Nikolay Raspopov 345cb5d947
Prefer existing and translated variant of home page (#342)
* Prefer existing and translated variant of home page as the site link in the menu header.
* More compact "cond"-version of fix.
2021-05-20 22:02:31 +02:00
Alex Shpak 553d378db3 Fix lighthouse remarks: icon sizes, noopener 2021-05-20 19:00:15 +02:00
Alex Shpak 195138cad0 Update roboto fonts 2021-05-20 11:28:51 +02:00
Alex Shpak 9b2e21f870 Refactor search, syntax error 2021-05-19 20:28:21 +02:00
Alex Shpak d7c644f0e7 Refactor search, prepare for pre-built indexing 2021-05-19 20:26:21 +02:00
Alex Shpak 843144dd85 Regression, fix menu reset script 2021-05-19 20:12:27 +02:00
Nikolay Raspopov 4d936a55d8
Fixed ineffective "disableHugoGeneratorInject" parameter (#337)
Fixed issue #336. HUGO does not use `{{ hugo.Generator }}` placeholder anymore.
2021-05-06 09:33:18 +02:00
Alex Shpak 6720168dd5 #281, Copy code block content on click 2021-05-03 23:52:00 +02:00
Alex Shpak 6a1932611c Update MermaidJS example 2021-05-03 23:14:20 +02:00
Alex Shpak e611f564bb Update archetypes 2021-05-03 23:06:43 +02:00
Alex Shpak f4a26ff3da Imporove sectiopn shortcode example 2021-05-03 22:59:33 +02:00
69 changed files with 304 additions and 323 deletions

View File

@ -41,7 +41,7 @@
Navigate to your hugo project root and run:
```
git submodule add https://git.soper.xyz/Soper/hugo-book themes/book
git submodule add https://github.com/alex-shpak/hugo-book themes/book
```
Then run hugo (or set `theme = "book"`/`theme: book` in configuration file)
@ -281,15 +281,21 @@ There are a few hugo templates inserted in `<head>`
- [Google Analytics](https://gohugo.io/templates/internal/#google-analytics)
- [Open Graph](https://gohugo.io/templates/internal/#open-graph)
To disable Open Graph inclusion you can create your own empty file `\layouts\_internal\opengraph.html`.
In fact almost empty not quite empty because an empty file looks like absent for HUGO. For example:
```
<!-- -->
```
## Shortcodes
- [Buttons](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/buttons/)
- [Columns](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/columns/)
- [Expand](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/expand/)
- [Hints](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/hints/)
- [KaTeX](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/katex/)
- [Mermaid](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/mermaid/)
- [Tabs](https://themes.gohugo.io/theme/hugo-book/docs/shortcodes/tabs/)
- [Buttons](https://hugo-book-demo.netlify.app/docs/shortcodes/buttons/)
- [Columns](https://hugo-book-demo.netlify.app/docs/shortcodes/columns/)
- [Details](https://hugo-book-demo.netlify.app/docs/shortcodes/details/)
- [Hints](https://hugo-book-demo.netlify.app/docs/shortcodes/hints/)
- [KaTeX](https://hugo-book-demo.netlify.app/docs/shortcodes/katex/)
- [Mermaid](https://hugo-book-demo.netlify.app/docs/shortcodes/mermaid/)
- [Tabs](https://hugo-book-demo.netlify.app/docs/shortcodes/tabs/)
By default, Goldmark trims unsafe outputs which might prevent some shortcodes from rendering. It is recommended to set `markup.goldmark.renderer.unsafe=true` if you encounter problems.

View File

@ -5,6 +5,6 @@ weight: 1
# bookToc: true
# bookHidden: false
# bookCollapseSection: false
# bookComments: true
draft: true
# bookComments: false
# bookSearchExclude: false
---

View File

@ -1,10 +0,0 @@
---
title: "{{ .Name | humanize | title }}"
weight: 1
# bookFlatSection: false
# bookToc: true
# bookHidden: false
# bookCollapseSection: false
# bookComments: true
draft: true
---

View File

@ -1,7 +1,6 @@
---
title: "{{ replace .Name "-" " " | title }}"
title: "{{ .Name | humanize | title }}"
date: {{ .Date }}
tags: []
categories: []
draft: true
# bookComments: false
# bookSearchExclude: false
---

View File

@ -1,7 +1,3 @@
/* You can add custom styles here. */
// @import "plugins/numbered";
//Uncomment the following if local fonts will not load
//@import url('https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap');
//@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

View File

@ -1,22 +1,12 @@
/* roboto-300italic - latin */
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 300;
font-display: swap;
src: local('Roboto Light Italic'), local('Roboto-LightItalic'),
url('fonts/roboto-v19-latin-300italic.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-v19-latin-300italic.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* roboto-regular - latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
font-display: swap;
src: local('Roboto'), local('Roboto-Regular'),
url('fonts/roboto-v19-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-v19-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
src: local(''),
url('fonts/roboto-v27-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-v27-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* roboto-700 - latin */
@font-face {
@ -24,9 +14,9 @@
font-style: normal;
font-weight: 700;
font-display: swap;
src: local('Roboto Bold'), local('Roboto-Bold'),
url('fonts/roboto-v19-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-v19-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
src: local(''),
url('fonts/roboto-v27-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-v27-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* roboto-mono-regular - latin */
@ -35,91 +25,15 @@
font-style: normal;
font-weight: 400;
font-display: swap;
src: local('Roboto Mono'), local('RobotoMono-Regular'),
url('fonts/roboto-mono-v6-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-mono-v6-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
src: local(''),
url('fonts/roboto-mono-v13-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('fonts/roboto-mono-v13-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* UBUNTU; LOADED BY SOPER */
/* Regular */
@font-face {
font-family: 'Ubuntu';
src: url('fonts/Ubuntu-Bold.woff2') format('woff2'),
url('fonts/Ubuntu-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu';
src: url('fonts/Ubuntu-Italic.woff2') format('woff2'),
url('fonts/Ubuntu-Italic.woff') format('woff');
font-weight: normal;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu';
src: url('fonts/Ubuntu-BoldItalic.woff2') format('woff2'),
url('fonts/Ubuntu-BoldItalic.woff') format('woff');
font-weight: bold;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu';
src: url('fonts/Ubuntu.woff2') format('woff2'),
url('fonts/Ubuntu.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
/* Mono */
@font-face {
font-family: 'Ubuntu Mono';
src: url('fonts/UbuntuMono-Bold.woff2') format('woff2'),
url('fonts/UbuntuMono-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu Mono';
src: url('fonts/UbuntuMono-BoldItalic.woff2') format('woff2'),
url('fonts/UbuntuMono-BoldItalic.woff') format('woff');
font-weight: bold;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu Mono';
src: url('fonts/UbuntuMono-Regular.woff2') format('woff2'),
url('fonts/UbuntuMono-Regular.woff') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Ubuntu Mono';
src: url('fonts/UbuntuMono-Italic.woff2') format('woff2'),
url('fonts/UbuntuMono-Italic.woff') format('woff');
font-weight: normal;
font-style: italic;
font-display: swap;
}
body {
font-family: 'Ubuntu', 'Roboto', sans-serif;
font-family: 'Roboto', sans-serif;
}
code {
font-family: 'Ubuntu Mono', 'Roboto Mono', monospace;
font-family: 'Roboto Mono', monospace;
}

View File

@ -86,11 +86,11 @@ ul.pagination {
.book-brand {
margin-top: 0;
margin-bottom: $padding-16;
img {
height: 1.5em;
width: auto;
vertical-align: middle;
width: 1.5em;
margin-inline-end: $padding-8;
}
}
@ -135,13 +135,20 @@ ul.pagination {
}
}
.book-section-flat {
margin-bottom: $padding-16 * 2;
&:not(:first-child) {
margin-top: $padding-16 * 2;
// for RTL support
body[dir="rtl"] .book-menu {
input.toggle + label::after {
content: "";
}
input.toggle:checked + label::after {
content: "";
}
}
.book-section-flat {
margin: $padding-16 * 2 0;
> a,
> span,
> label {
@ -170,6 +177,11 @@ ul.pagination {
label {
line-height: 0;
}
img.book-icon {
height: 1.5em;
width: 1.5em;
}
}
.book-search {
@ -226,6 +238,7 @@ ul.pagination {
img {
height: 1em;
width: 1em;
}
nav > ul > li:first-child {
@ -237,9 +250,20 @@ ul.pagination {
padding-top: $padding-16;
font-size: $font-size-14;
a {
margin: $padding-8 0;
}
img {
height: 1em;
margin-inline-end: $padding-8;
width: 1em;
&:first-child {
margin-inline-end: $padding-8;
}
&:last-child {
margin-inline-start: $padding-8;
}
}
}
@ -248,60 +272,17 @@ ul.pagination {
}
.book-languages {
position: relative;
overflow: visible;
margin-block-end: $padding-16 * 2;
padding: $padding-16;
margin: -$padding-16;
.book-icon {
height: 1em;
width: 1em;
margin-inline-end: .5em;
}
ul {
margin: 0;
padding: 0;
list-style: none;
li {
white-space: nowrap;
cursor: pointer;
}
padding-inline-start: 1.5em;
}
&:hover,
&:focus,
&:focus-within {
.book-languages-list {
display: block;
}
}
.book-languages-list {
display: none;
position: absolute;
bottom: 100%;
left: 0;
padding: $padding-8 0;
background: var(--body-background);
box-shadow: 0 0 $padding-4 rgba(0, 0, 0, 0.1);
li img {
opacity: 0.25;
}
li.active img,
li:hover img {
opacity: initial;
}
a {
color: inherit;
padding: $padding-8 $padding-16;
}
}
}
.book-home {
padding: $padding-16;
}
// Responsive styles
@ -374,8 +355,8 @@ ul.pagination {
}
}
//for RTL support
body[dir="rtl"] #menu-control:checked + main {
// for RTL support
body[dir="rtl"] #menu-control:checked ~ main {
.book-menu .book-menu-content {
transform: translateX(-$menu-width);
}

View File

@ -138,7 +138,7 @@
}
dd {
margin-inline-start: $padding-16;
margin-inline-start: 0;
margin-bottom: $padding-16;
}
}

21
assets/clipboard.js Normal file
View File

@ -0,0 +1,21 @@
(function () {
function select(element) {
const selection = window.getSelection();
const range = document.createRange();
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
}
document.querySelectorAll("pre code").forEach(code => {
code.addEventListener("click", function (event) {
select(code.parentElement);
if (navigator.clipboard) {
navigator.clipboard.writeText(code.parentElement.textContent);
}
});
});
})();

View File

@ -1,5 +1,5 @@
(function() {
var menu = document.querySelector("aside.book-menu nav");
var menu = document.querySelector("aside .book-menu-content");
addEventListener("beforeunload", function(event) {
localStorage.setItem("menu.scrollTop", menu.scrollTop);
});

View File

@ -1,32 +0,0 @@
'use strict';
(function () {
const indexCfg = {{ with i18n "bookSearchConfig" }}
{{ . }};
{{ else }}
{};
{{ end }}
indexCfg.doc = {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href', 'section'],
};
const index = FlexSearch.create('balance', indexCfg);
window.bookSearchIndex = index;
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
{{- $pages = where $pages "Params.booksearchexclude" "!=" true -}}
{{- $pages = where $pages "Content" "not in" (slice nil "") -}}
{{ range $index, $page := $pages }}
index.add({
'id': {{ $index }},
'href': '{{ $page.RelPermalink }}',
'title': {{ (partial "docs/title" $page) | jsonify }},
'section': {{ (partial "docs/title" $page.Parent) | jsonify }},
'content': {{ $page.Plain | jsonify }}
});
{{- end -}}
})();

15
assets/search-data.json Normal file
View File

@ -0,0 +1,15 @@
[
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
{{- $pages = where $pages "Params.booksearchexclude" "!=" true -}}
{{- $pages = where $pages "Content" "not in" (slice nil "") -}}
{{ range $index, $page := $pages }}
{{ if gt $index 0}},{{end}} {
"id": {{ $index }},
"href": "{{ $page.RelPermalink }}",
"title": {{ (partial "docs/title" $page) | jsonify }},
"section": {{ (partial "docs/title" $page.Parent) | jsonify }},
"content": {{ $page.Plain | jsonify }}
}
{{- end -}}
]

View File

@ -1,9 +1,19 @@
'use strict';
{{ $searchDataFile := printf "%s.search-data.js" .Language.Lang }}
{{ $searchData := resources.Get "search-data.js" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}
{{ $searchDataFile := printf "%s.search-data.json" .Language.Lang }}
{{ $searchData := resources.Get "search-data.json" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify | resources.Fingerprint }}
{{ $searchConfig := i18n "bookSearchConfig" | default "{}" }}
(function () {
const searchDataURL = '{{ $searchData.RelPermalink }}';
const indexConfig = Object.assign({{ $searchConfig }}, {
doc: {
id: 'id',
field: ['title', 'content'],
store: ['title', 'href', 'section']
}
});
const input = document.querySelector('#book-search-input');
const results = document.querySelector('#book-search-results');
@ -46,11 +56,14 @@
input.removeEventListener('focus', init); // init once
input.required = true;
loadScript('{{ "flexsearch.min.js" | relURL }}');
loadScript('{{ $searchData.RelPermalink }}', function () {
input.required = false;
search();
});
fetch(searchDataURL)
.then(pages => pages.json())
.then(pages => {
window.bookSearchIndex = FlexSearch.create('balance', indexConfig);
window.bookSearchIndex.add(pages);
})
.then(() => input.required = false)
.then(search);
}
function search() {
@ -75,20 +88,6 @@
});
}
/**
* @param {String} src
* @param {Function} callback
*/
function loadScript(src, callback) {
const script = document.createElement('script');
script.defer = true;
script.async = false;
script.src = src;
script.onload = callback;
document.head.appendChild(script);
}
/**
* @param {String} content
* @returns {Node}

View File

@ -1,6 +1,6 @@
# Mermaid Chart
[Mermaid](https://mermaidjs.github.io/) is library for generating svg charts and diagrams from text.
[MermaidJS](https://mermaid-js.github.io/) is library for generating svg charts and diagrams from text.
{{< hint info >}}
**Override Mermaid Initialization Config**
@ -14,33 +14,28 @@ create a `mermaid.json` file in your `assets` folder!
{{< columns >}}
```tpl
{{</* mermaid [class="text-center"]*/>}}
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
alt is sick
Bob->>Alice: Not so good :(
else is well
Bob->>Alice: Feeling fresh like a daisy
end
opt Extra response
Bob->>Alice: Thanks for asking
end
stateDiagram-v2
State1: The state with a note
note right of State1
Important information! You can write
notes.
end note
State1 --> State2
note left of State2 : This is the note to the left.
{{</* /mermaid */>}}
```
<--->
{{< mermaid >}}
sequenceDiagram
Alice->>Bob: Hello Bob, how are you?
alt is sick
Bob->>Alice: Not so good :(
else is well
Bob->>Alice: Feeling fresh like a daisy
end
opt Extra response
Bob->>Alice: Thanks for asking
end
stateDiagram-v2
State1: The state with a note
note right of State1
Important information! You can write
notes.
end note
State1 --> State2
note left of State2 : This is the note to the left.
{{< /mermaid >}}
{{< /columns >}}

View File

@ -0,0 +1,6 @@
# First page
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
<!--more-->
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -1 +0,0 @@
# Page 1

View File

@ -1 +0,0 @@
# Page 2

View File

@ -0,0 +1,6 @@
# Second Page
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
<!--more-->
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -1 +1 @@
{"Target":"book.min.5ac6c2989f0943405962be6800b442aef429ef26ade26545ecf0617a21d1197a.css","MediaType":"text/css","Data":{"Integrity":"sha256-WsbCmJ8JQ0BZYr5oALRCrvQp7yat4mVF7PBheiHRGXo="}}
{"Target":"book.min.ad694c0f1601cd801d432bdb4a6abae57aa202e0cec7e44e2f6ab46fbe7b628c.css","MediaType":"text/css","Data":{"Integrity":"sha256-rWlMDxYBzYAdQyvbSmq65XqiAuDOx+ROL2q0b757Yow="}}

20
i18n/fa.yaml Normal file
View File

@ -0,0 +1,20 @@
- id: Search
translation: جستجو
- id: Edit this page
translation: این صفحه را ویرایش کنید
- id: Last modified by
translation: آخرین بار ویرایش شده توسط
- id: Expand
translation: بسط دادن
- id: Categories
translation: دسته بندی ها
- id: Tags
translation: تگ ها
- id: bookSearchConfig
translation: '{ cache: true, encode: false, rtl: true, split: /\s+/, tokenize: "forward"}'

14
i18n/it.yaml Normal file
View File

@ -0,0 +1,14 @@
- id: Search
translation: Cerca
- id: Edit this page
translation: Modifica questa pagina
- id: Last modified by
translation: Ultima modifica di
- id: Expand
translation: Espandi
- id: bookSearchConfig
translation: '{ cache: true }'

View File

@ -8,7 +8,6 @@
<style>
.not-found {
text-align: center;
font-family: 'Consolas', monospace;
}
.not-found h1 {
margin: .25em 0 0 0;

View File

@ -1,12 +1,9 @@
<!DOCTYPE html>
<html lang="{{ .Site.Language.Lang }}" dir="{{ .Site.Language.LanguageDirection | default "ltr" }}">
<head>
{{ hugo.Generator }}
{{ partial "docs/html-head" . }}
{{ partial "docs/inject/head" . }}
</head>
<body dir="{{ .Site.Language.LanguageDirection | default "ltr" }}">
<input type="checkbox" class="hidden toggle" id="menu-control" />
<input type="checkbox" class="hidden toggle" id="toc-control" />
@ -47,7 +44,6 @@
{{ partial "docs/inject/body" . }}
</body>
</html>
{{ define "menu" }}

View File

@ -1,5 +1,5 @@
<h2 class="book-brand">
<a href="{{ .Site.BaseURL | relLangURL }}">
<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 -}}

View File

@ -1,25 +1,26 @@
<div class="flex flex-wrap justify-between">
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}
{{ 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>
{{- $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>
{{ 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>
<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>
{{ end }}
</div>
{{ partial "docs/prev-next" . }}
{{ $script := resources.Get "clipboard.js" | resources.Minify }}
{{ with $script.Content }}
<script>{{ . | safeJS }}</script>
{{ end }}

View File

@ -12,22 +12,23 @@
<link rel="icon" href="{{ "favicon.png" | relURL }}" type="image/x-icon">
{{- range .Translations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .Permalink }}" title="{{ partial "docs/title" . }}">
{{ end -}}
<link rel="alternate" hreflang="{{ .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" . | resources.ToCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Integrity }}">
<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="{{ $searchJS.RelPermalink }}" integrity="{{ $searchJS.Data.Integrity }}"></script>
{{- 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 }}" integrity="{{ $swJS.Data.Integrity }}"></script>
{{- 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_async.html" . -}}
@ -41,3 +42,9 @@
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 -}}

View File

@ -2,7 +2,7 @@
{{ $bookTranslatedOnly := default false .Site.Params.BookTranslatedOnly }}
{{ $translations := dict }}
{{ if (eq $bookTranslatedOnly false ) }}
{{ range .Site.Home.AllTranslations }}
{{ range .Site.Home.Translations }}
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
{{ end }}
@ -10,22 +10,24 @@
{{ $translations = merge $translations (dict .Language.Lang .) }}
{{ end }}
<div class="book-languages" tabindex="0" aria-haspopup="true">
<ul>
<li class="flex align-center">
<img src="{{ "svg/translate.svg" | relURL }}" class="book-icon" alt="Languages" />
{{ $.Site.Language.LanguageName }}
</li>
</ul>
<ul class="book-languages-list">
{{ range .Site.Languages }}{{ with index $translations .Lang }}
<li class="{{ if (eq $.Site.Language .Language) }}active{{ end }}">
<a href="{{ .Permalink }}" class="flex align-center">
<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" />
{{ .Language.LanguageName }}
{{ $.Site.Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</div>
</label>
<ul>
{{ range .Site.Languages }}{{ with index $translations .Lang }}
<li>
<a href="{{ .Permalink }}">
{{ .Language.LanguageName }}
</a>
</li>
{{ end }}{{ end }}
</ul>
</li>
</ul>

View File

@ -1,4 +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 }}

View File

@ -31,7 +31,7 @@
{{ 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.Permalink }}"{{ end }} class="{{ if $current }}active{{ end }}">
<a {{ if .Page.Content }}href="{{ .Page.Permalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}}
</a>
</label>

View File

@ -1,6 +1,9 @@
<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 }}

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,27 @@
{{ $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">
{{ with $prev }}
<a href="{{ .RelPermalink }}" class="flex align-center float-left book-icon">
<img src="{{ "svg/backward.svg" | relURL }}" alt="Previous" title="{{ partial "docs/title" . }}" />
<span>{{ partial "docs/title" . }}</span>
</a>
{{ end }}
{{ with $next }}
<a href="{{ .RelPermalink }}" class="flex align-center float-right book-icon">
<span>{{ partial "docs/title" . }}</span>
<img src="{{ "svg/forward.svg" | relURL }}" alt="Next" title="{{ partial "docs/title" . }}" />
</a>
{{ end }}
</div>
{{ end -}}
{{ end }}

View File

@ -7,6 +7,6 @@
{{ with .Get "relref" }}
{{ $ref = relref $ . }}
{{ end }}
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
{{ $.Inner | markdownify }}
</a>

View File

@ -1,7 +1,7 @@
<div class="book-columns flex flex-wrap">
{{ range split .Inner "<--->" }}
{{ range split .Inner "<--->" }}
<div class="flex-even markdown-inner">
{{ . | markdownify }}
{{ . | $.Page.RenderString }}
</div>
{{ end }}
{{ end }}
</div>

View File

@ -3,7 +3,7 @@
<dt>
<a href="{{ .RelPermalink }}">{{ partial "docs/title" . }}</a>
</dt>
<dd>
<dd class="markdown-inner">
{{ default .Summary .Description }}
</dd>
{{ end }}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
static/svg/backward.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>

After

Width:  |  Height:  |  Size: 198 B

1
static/svg/forward.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/></svg>

After

Width:  |  Height:  |  Size: 195 B

View File

@ -6,6 +6,7 @@ license = "MIT"
licenselink = "https://github.com/alex-shpak/hugo-book/blob/master/LICENSE"
description = "Hugo documentation theme as simple as plain book"
homepage = "https://github.com/alex-shpak/hugo-book"
demosite = "https://hugo-book-demo.netlify.app"
tags = ["responsive", "clean", "documentation", "docs", "flexbox", "search", "mobile", "multilingual", "disqus"]
features = []
min_version = "0.68"