Breaking changes, rewrite; add support for plain text output and single page mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<h2 class="book-brand">
|
||||
<a class="flex align-center" href="{{ cond (not .Site.Home.File) hugo.Sites.Default.Home.RelPermalink .Site.Home.RelPermalink }}">
|
||||
<a class="flex align-center" href="{{ partial "docs/links/home" . }}">
|
||||
{{- with .Site.Params.BookLogo -}}
|
||||
<img src="{{ . | relURL }}" alt="{{ partial "docs/text/i18n" "Logo" }}" />
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<!-- This partial can be replaced to support other commenting engines -->
|
||||
{{/* This partial can be replaced to support other commenting engines */}}
|
||||
{{ partial "disqus.html" . }}
|
||||
|
||||
@@ -1,6 +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) -}}
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ with .OutputFormats.Get "txt" }}
|
||||
<a class="flex align-center" href="{{ .RelPermalink }}">
|
||||
<img src="{{ partial "docs/icon" "markdown" }}" class="book-icon" alt="{{ partial "docs/text/i18n" "Markdown" }}" />
|
||||
<span>{{ partial "docs/text/i18n" "Source" }}</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">
|
||||
|
||||
@@ -47,9 +47,8 @@ https://github.com/alex-shpak/hugo-book
|
||||
|
||||
{{ 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 }}
|
||||
{{- range .AlternativeOutputFormats -}}
|
||||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}
|
||||
{{ end -}}
|
||||
|
||||
{{- define "integrity" -}}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{{ return cond (not .Site.Home.File) hugo.Sites.Default.Home.RelPermalink .Site.Home.RelPermalink }}
|
||||
@@ -1,9 +1,4 @@
|
||||
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
||||
{{ if eq $bookSection "*" }}
|
||||
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
|
||||
{{ end }}
|
||||
|
||||
{{ with .Site.GetPage $bookSection }}
|
||||
{{ with (partialCached "docs/menu-section" .Site) }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $) }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
{{/*
|
||||
This is template for hugo menus, accepts Page and Menu as context
|
||||
https://gohugo.io/variables/menus/
|
||||
-->
|
||||
*/}}
|
||||
{{- if .Menu -}}
|
||||
{{- template "book-menu-hugo" . -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{{/* Recursively creates a slice of pages under given page */}}
|
||||
|
||||
{{ define "book-menu-recurse" }}
|
||||
{{ if not .Page.Params.BookHidden }}
|
||||
{{ if .Page.Content }}
|
||||
{{ .Scratch.Add "BookPages" (slice .Page) }}
|
||||
{{ end }}
|
||||
{{ range .Page.Pages }}
|
||||
{{ template "book-menu-recurse" (dict "Scratch" $.Scratch "Page" .) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $scratch := newScratch }}
|
||||
{{ template "book-menu-recurse" (dict "Scratch" $scratch "Page" .) }}
|
||||
{{ return $scratch.Get "BookPages" }}
|
||||
@@ -0,0 +1,8 @@
|
||||
{{/* returns the section to be rendered as menu */}}
|
||||
{{ $bookSection := default "docs" .Params.BookSection }}
|
||||
{{ $section := .GetPage (cond (eq $bookSection "*") "/" $bookSection) }}
|
||||
{{ if $section }}
|
||||
{{ return $section }}
|
||||
{{ else }}
|
||||
{{ errorf "%s: Section '%s' not found, check BookSection theme parameter" $ $bookSection }}
|
||||
{{ end }}
|
||||
@@ -1,14 +0,0 @@
|
||||
{{ $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" }}
|
||||
@@ -1,14 +1,9 @@
|
||||
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
||||
{{ if eq $bookSection "*" }}
|
||||
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
|
||||
{{ end }}
|
||||
{{- with (partialCached "docs/menu-section" .Site) -}}
|
||||
{{- $pages := partialCached "docs/menu-section-pages" . -}}
|
||||
{{- $prev := $pages.Next $ -}}
|
||||
{{- $next := $pages.Prev $ -}}
|
||||
|
||||
{{ with .Site.GetPage $bookSection }}
|
||||
{{ $pages := partialCached "docs/prev-next-cache" .Pages }}
|
||||
{{ $prev := $pages.Next $ }}
|
||||
{{ $next := $pages.Prev $ }}
|
||||
|
||||
{{- if or $prev $next }}
|
||||
{{- if or $prev $next -}}
|
||||
<div class="flex flex-wrap justify-between">
|
||||
<span>
|
||||
{{ with $prev }}
|
||||
@@ -27,5 +22,5 @@
|
||||
{{ end }}
|
||||
</span>
|
||||
</div>
|
||||
{{ end -}}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<!--
|
||||
{{/*
|
||||
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 -}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
{{/*
|
||||
Partial to generate page name from Title or File name.
|
||||
Accepts Page as context
|
||||
-->
|
||||
*/}}
|
||||
{{ $title := "" }}
|
||||
|
||||
{{ if .LinkTitle }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{- return and
|
||||
(not (eq .Params.bookToC false))
|
||||
(not (eq .Site.Params.BookToC false))
|
||||
(not (eq .TableOfContents "<nav id=\"TableOfContents\"></nav>"))
|
||||
-}}
|
||||
|
||||
Reference in New Issue
Block a user