#43, Update tree menu rendering to support multiple sections
This commit is contained in:
parent
0084e069de
commit
0b30289d9f
18 changed files with 249 additions and 69 deletions
|
@ -26,7 +26,7 @@ git submodule add https://github.com/alex-shpak/hugo-book themes/book
|
|||
|
||||
Then run hugo (or set `theme: book` in configuration file)
|
||||
```
|
||||
hugo server --theme book
|
||||
hugo server --minify --theme book
|
||||
```
|
||||
|
||||
### Creating site from scratch
|
||||
|
@ -38,7 +38,7 @@ git submodule add https://github.com/alex-shpak/hugo-book themes/book
|
|||
cp -R themes/book/exampleSite/content .
|
||||
```
|
||||
```sh
|
||||
hugo server --theme book
|
||||
hugo server --minify --theme book
|
||||
```
|
||||
|
||||
## Menu
|
||||
|
|
|
@ -5,14 +5,15 @@ $block-border-radius: 0.15rem;
|
|||
.markdown {
|
||||
line-height: 1.7;
|
||||
|
||||
> :first-child {
|
||||
margin-top: 0;
|
||||
line-height: 1em;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-weight: 400;
|
||||
line-height: 1.25;
|
||||
|
||||
// remove padding at the beginning of page
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
line-height: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
b, optgroup, strong {
|
||||
|
|
|
@ -106,6 +106,18 @@ ul.pagination {
|
|||
@include dark-links;
|
||||
}
|
||||
|
||||
.book-section-flat {
|
||||
margin-bottom: $padding-16 * 2;
|
||||
|
||||
> a, > span {
|
||||
font-weight: 600
|
||||
}
|
||||
|
||||
> ul {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.book-page {
|
||||
min-width: $body-min-width;
|
||||
flex-grow: 1;
|
||||
|
@ -213,6 +225,7 @@ aside nav,
|
|||
// Extra space for big screens
|
||||
@media screen and (min-width: $container-max-width) {
|
||||
.book-page,
|
||||
.book-posts,
|
||||
.book-menu nav,
|
||||
.book-toc nav {
|
||||
padding: $padding-16 * 2 $padding-16;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# hugo server --themesDir ... --baseURL=http://0.0.0.0:1313/example
|
||||
# hugo server --minify --themesDir ... --baseURL=http://0.0.0.0:1313/example
|
||||
|
||||
baseURL: https://example.com/
|
||||
title: Hugo Book
|
||||
|
|
4
exampleSite/content/docs/_index.md
Normal file
4
exampleSite/content/docs/_index.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
weight: 1
|
||||
bookFlatSection: true
|
||||
---
|
42
exampleSite/content/docs/fida-abluere/_index.md
Normal file
42
exampleSite/content/docs/fida-abluere/_index.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Fida abluere audiat moram ferarum terram virgae
|
||||
|
||||
## Facere fluidove ab naides ut sic cornu
|
||||
|
||||
Lorem markdownum Lucifer est, ire tangit inposito terram. Ore et pes lavet nuper
|
||||
longam, longa sub, erat nec Lemnicolae, in.
|
||||
[Et](http://sumparvi.org/ossaquerecludit) nec tantaque sollicitive cognovi et ut
|
||||
videbar verso **passis**, Epimethida tutos. Dedecus Desine morae.
|
||||
|
||||
Fervens esse et tenet cinisque per: et vir equus formaque superorum tollit,
|
||||
vires meae magnum; Latona. Fundamine potitur genialis: imagine gaudet et herba
|
||||
rura vates horrendum, laborum quis: potero aureus habitantque illos nox? E
|
||||
factorum breve ad in verum Euboea templis volitat pompa aureus pallebant
|
||||
videres, replet inque color? Capit et bipennem Finis sonuere magno nec pennis
|
||||
exhortatur tenebat, ait.
|
||||
|
||||
## Gurgite caede Hippocoon auxilio furit
|
||||
|
||||
Freta amatos. [Saxum](http://horas-pericula.net/inprudens.php) vocanti Iovem sui
|
||||
quicquam viro linguae minus, ara nec tu ipsa ars miserae, quam tetigit vacet
|
||||
inque. Fuistis Deucalion, populi invidiae *indicat texere est* Helicon simul.
|
||||
|
||||
1. Hominum quantaque membra duos
|
||||
2. Domum tela
|
||||
3. Totus penna
|
||||
4. Charaxi cogitis Hoc caelo est removit Anubis
|
||||
5. Simulacra Delo posset insula
|
||||
6. Infelix et nox fixa adhuc
|
||||
|
||||
## Trabes per coercet mittere toro
|
||||
|
||||
Cerae movit: patria quid, Alpheias **magicaeque** puer! Cum venit quidem, sors
|
||||
erigor coniunctis sparsa carpe periuria in vultu temperat gradibus. Tutus
|
||||
fecimus, caput; flamma mentis retia fuit Pallas.
|
||||
|
||||
> Arbore et agitasse partes patrem dumque ab, nec infans, sollemnia summis
|
||||
> resque, de malles ille? Ultor fugaverat nemus, quaerenti nolle coniugis
|
||||
> manibus contraque pace. Fuit verba ipse ignavi vulnus. Nam illud *inferius*
|
||||
> iuvenale iuncta tandem.
|
||||
|
||||
Deus hostia Peneidas ad passu in venerat postes
|
||||
[nymphae](http://ullo-herbae.org/). Sagittis tabo sibi marmoreum.
|
60
exampleSite/content/docs/fida-abluere/ego-numen.md
Normal file
60
exampleSite/content/docs/fida-abluere/ego-numen.md
Normal file
|
@ -0,0 +1,60 @@
|
|||
# Ego numen obest
|
||||
|
||||
## Mors curru Iove pedibus curva humano salutem
|
||||
|
||||
Lorem markdownum, mole, profugus. Madida ne quantus, pars verba lacrimis
|
||||
memorique longius cupidi ipse attrahit et. Vota liberiore rector suos fallit
|
||||
videor iustissimus barbara quod habet. Tantum patriaeque *omnia spectes* inimica
|
||||
mari nec spemque ululare: nuper quodque, sic, quo.
|
||||
|
||||
var php_wireless = 4;
|
||||
siteWinsock.switch_inbox += so_control_logic;
|
||||
if (target_website.bugCopyrightIcs.cms_digital_method(mca_active) >
|
||||
cloneScrollHttps) {
|
||||
https_drop_hard(97, sshPayload + autoresponder_bmp_file);
|
||||
hypertextCommercialBookmark = optical_impact;
|
||||
}
|
||||
architecture = userRate.unfriend(petabyteFile(irc, wave,
|
||||
logic_tag.impact.cookie_favorites(5, 83)), listserv, malware_cad(
|
||||
disk));
|
||||
|
||||
Populi annum deprendere suae recumbis in sedem starent! Super non accedat
|
||||
percepitque negare inconcessisque habitare: puerum: picta. Haec natamque, in
|
||||
rubentem auctore quantas oetaeas **certamine** levatae sollicitumque mecum vultu
|
||||
obstructaque. Limina subtemen qui trepidare virgine! Enim rumor paenituit haec
|
||||
**crimine Melampus** sidus.
|
||||
|
||||
## Partem robora herbae ilice hic exspectatus tepidique
|
||||
|
||||
Heu fugit carne, illo ex Iunonis ut tempora sacrata, adhaesi. Fallunt eque
|
||||
amnes!
|
||||
|
||||
1. Vile ille res sidera gaudebat felicia auxilium
|
||||
2. Sacra curam adfusique vasti progenitore omnia nutantem
|
||||
3. Quod notum spesque extentam fores in voces
|
||||
4. In qualia aequo
|
||||
5. Auro commoda
|
||||
6. Mearum huic volucres locorum formosus
|
||||
|
||||
## Invidiae fidemque cogamque esset potentia Minos
|
||||
|
||||
Sub silicem, semesaque nec, pone pariterque tendentem, in pactae suarum recurvas
|
||||
et contra tu minister via. Subducere tangeris neque coniunxque utque. Virga
|
||||
altam, mortemque: **ubi** procul, et vidi committit. Et
|
||||
[Alpheos](http://nivea-pavens.io/ferroclara.html)! Perfide age magna per aequor
|
||||
abstulerat, Boeotia sentit succincta ad linquit confugisse certae, de dignatur
|
||||
et!
|
||||
|
||||
> Sic nacta saxo *crura*, iustis rorantia premens tempora lecte sumpsisse
|
||||
> nusquam ulvam, apta! Sed sub plumas consueta quae; tibi mihi nec committi
|
||||
> mundi?
|
||||
|
||||
Ipsa dea serpentum illic; aspicit reticere Aeaciden mitto; est novis exul.
|
||||
Invidit senior vela, cava sed plumae vident ille ipse domo litus ac fallere
|
||||
lumina, nisi famem cycno.
|
||||
|
||||
Nunc miserata admisitque [nata](http://mollibus.net/secessitnostrique), cum
|
||||
loco, **iacerent**, te medullas matres. Fraude tamen, prorumpit puerum primo
|
||||
polus regalia pampineis iungunt nec, aderis replent carituraque cervus.
|
||||
Primusque lapides ad inpia pedibus; non fare praeterit penetralia in pedum uror.
|
||||
Rapitur vivis lacrimis, vena et *dixit*.
|
48
exampleSite/content/docs/fida-abluere/natusque.md
Normal file
48
exampleSite/content/docs/fida-abluere/natusque.md
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Natusque putat tu vero
|
||||
|
||||
## Scylaceaque neve coepisse
|
||||
|
||||
Lorem markdownum hostem et addit arbusta iacuit laetissimus medio, quae quoque
|
||||
faciente. Belli et fuerant fuerat, curas Abas equos sacerdos iactasque videndo
|
||||
tanto, sub. Et simulasse caedis, est nec acre addiderat, manet Phrygiae
|
||||
quisquam, ater, aura sua **deique cornua**. Bacchi *dixi* cum tollit, ad
|
||||
sinistra mirum, non se dis fraudare in decimo vocet. Ducunt **Acrisio sine
|
||||
ratem**: enim illas venti, ferit nam ora.
|
||||
|
||||
> Crescente cernis ritusque et vertice potui, fugam conferat enim, quin te Iuno,
|
||||
> Calydonia! Cursum est suo lassant quam cutis virgo urbe illa auras, finem.
|
||||
> [Trabem est](http://www.tutus.io/) secedere Bybli laudant quercus tribuitque
|
||||
> relinque et cornua ora, et quoniam maledicere viscera caelobracchia omne hoc.
|
||||
> Metaque Arcas patet *intraverat tenet*.
|
||||
|
||||
Silvisque primae tulisset sive sonuere, incola visa veniat temptantes spernimur
|
||||
et dictis se. Sub gerunt. Aqua [tantum templi](http://www.dextra.net/)
|
||||
peregrinis ut *aevo cuique* falsi, ibat avidae transitus.
|
||||
|
||||
## Modo auctor imbres est
|
||||
|
||||
Clanis cernere monstravit illic quoque, in ignis male una deme? Alta sonanti
|
||||
relatus Pindo: nisi Pico edidit data tamen rurigenae avoque. Quotiens vela petis
|
||||
inposuit et parte utque, tempus pars contendere facturus tumidus. Flores
|
||||
culpavit fera retinens, vita puer publica ferebat positas.
|
||||
|
||||
if (mashupTopologyMnemonic(70) >= domain_correction_schema) {
|
||||
romTeraflops = log_android;
|
||||
mms_vrml_alignment(keyboard, oop, computerCodec);
|
||||
}
|
||||
retina_samba_arp *= desktop_itunes_mainframe(leopard, 511935) * 88 /
|
||||
direct_excel(-3, infringement_bespoke_apache, cmyk);
|
||||
drivePowerPlay.registryAix += dma;
|
||||
text_data.upsOdbc = error(user(processor_token_forum) * art_ajax_ldap);
|
||||
|
||||
Patriaque volvitur scire Naryciusque iuvenem dixit adfusique bicorni cupido.
|
||||
Tecumque corpore sublato, mox hostibus et muneris, non. Draconum noscit dapibus
|
||||
scopulis spondere lupum diro, illo ille victoque cibis; umentia spes.
|
||||
|
||||
Alumno est postquam gracili adnuimusque ore est praemia, ulla patitur: te disce
|
||||
erat cruribus prosunt. Arboris illis neque, et erubuit Gallicus: iam remisit
|
||||
adimuntque adsuerat nolit attonitus! Torvamque sensi ut fecundo fortuna bracchia
|
||||
fuerant, semper de manet inseris.
|
||||
|
||||
Ictibus in cursus in, in isque Polyxena et Solis oris pressa exclamat *in tori*
|
||||
lactente. [Locoque](http://est.net/et.html) iam fata Stygia lege transire.
|
|
@ -1 +1 @@
|
|||
.markdown{line-height:1.7}.markdown>:first-child{margin-top:0;line-height:1em}.markdown h1,.markdown h2,.markdown h3,.markdown h4,.markdown h5{font-weight:400;line-height:1.25}.markdown b,.markdown optgroup,.markdown strong{font-weight:700}.markdown a{text-decoration:none}.markdown a:hover{text-decoration:underline}.markdown code{font-family:oxygen mono,monospace;padding:0 .25rem;background:#f8f9fa;border-radius:.15rem}.markdown pre{padding:1rem;background:#f8f9fa;border-radius:.15rem;font-size:.875rem;overflow-x:auto}.markdown blockquote{border-left:2px solid #dee2e6;margin:0;padding:1px 1rem}.markdown blockquote :first-child{margin-top:0}.markdown blockquote :last-child{margin-bottom:0}.markdown table{border-spacing:0;border-collapse:collapse}.markdown table tr th,.markdown table tr td{padding:.5rem 1rem;line-height:1;border:1px solid #e9ecef}.markdown table tr:nth-child(2n){background:#f8f9fa}.flex{display:flex}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.align-center{align-items:center}.mx-auto{margin:0 auto}.mr-auto{margin-right:auto}.hide{display:none}html{font-size:16px;letter-spacing:.33px;scroll-behavior:smooth}html,body{min-width:20rem;overflow-x:hidden}body{color:#343a40;background:#fff;font-family:oxygen,sans-serif;font-weight:400;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;box-sizing:border-box}body *{box-sizing:inherit}h1,h2,h3,h4,h5{font-weight:400}a{text-decoration:none;color:#004ed0}a:visited{color:#8440f1}img{vertical-align:middle}aside nav ul{padding:0;margin:0;list-style:none}aside nav ul li{margin:1em 0}aside nav ul a{display:block}aside nav ul a:hover{opacity:.5}aside nav ul ul{padding-left:1rem}ul.pagination{display:flex;justify-content:center}ul.pagination .page-item a{padding:1rem}.container{max-width:80rem;margin:0 auto}.book-brand{margin-top:0}.book-menu{flex:0 0 16rem;font-size:.875rem}.book-menu nav{width:16rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-menu a{color:#343a40}.book-menu a.active{color:#004ed0}.book-page{min-width:20rem;flex-grow:1;padding:1rem}.book-header{margin-bottom:1rem;display:none}.book-toc{flex:0 0 14rem;font-size:.75rem}.book-toc nav{width:14rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-toc nav>ul>li{margin:0}.book-git-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-git-footer img{width:.875rem;vertical-align:bottom}.book-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-footer img{width:.875rem;vertical-align:bottom}.book-posts{min-width:20rem;max-width:41rem;flex-grow:1;padding:1rem}.book-posts article{padding-bottom:1rem}aside nav,.book-page,.book-posts,.markdown{transition:.2s ease-in-out;transition-property:transform,margin-left,opacity;will-change:transform,margin-left}@media screen and (max-width:55rem){.book-toc{display:none}}@media screen and (max-width:41rem){.book-menu{margin-left:-16rem}.book-header{display:flex}#menu-control:checked+main .book-menu nav,#menu-control:checked+main .book-page,#menu-control:checked+main .book-posts{transform:translateX(16rem)}#menu-control:checked+main .book-header label{transform:rotate(90deg)}#menu-control:checked+main .markdown{opacity:.25}}@media screen and (min-width:80rem){.book-page,.book-menu nav,.book-toc nav{padding:2rem 1rem}}
|
||||
.markdown{line-height:1.7}.markdown h1,.markdown h2,.markdown h3,.markdown h4,.markdown h5{font-weight:400;line-height:1.25}.markdown h1:first-child,.markdown h2:first-child,.markdown h3:first-child,.markdown h4:first-child,.markdown h5:first-child{margin-top:0;line-height:1em}.markdown b,.markdown optgroup,.markdown strong{font-weight:700}.markdown a{text-decoration:none}.markdown a:hover{text-decoration:underline}.markdown code{font-family:oxygen mono,monospace;padding:0 .25rem;background:#f8f9fa;border-radius:.15rem}.markdown pre{padding:1rem;background:#f8f9fa;border-radius:.15rem;font-size:.875rem;overflow-x:auto}.markdown blockquote{border-left:2px solid #dee2e6;margin:0;padding:1px 1rem}.markdown blockquote :first-child{margin-top:0}.markdown blockquote :last-child{margin-bottom:0}.markdown table{border-spacing:0;border-collapse:collapse}.markdown table tr th,.markdown table tr td{padding:.5rem 1rem;line-height:1;border:1px solid #e9ecef}.markdown table tr:nth-child(2n){background:#f8f9fa}.flex{display:flex}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.align-center{align-items:center}.mx-auto{margin:0 auto}.mr-auto{margin-right:auto}.hide{display:none}html{font-size:16px;letter-spacing:.33px;scroll-behavior:smooth}html,body{min-width:20rem;overflow-x:hidden}body{color:#343a40;background:#fff;font-family:oxygen,sans-serif;font-weight:400;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;box-sizing:border-box}body *{box-sizing:inherit}h1,h2,h3,h4,h5{font-weight:400}a{text-decoration:none;color:#004ed0}a:visited{color:#8440f1}img{vertical-align:middle}aside nav ul{padding:0;margin:0;list-style:none}aside nav ul li{margin:1em 0}aside nav ul a{display:block}aside nav ul a:hover{opacity:.5}aside nav ul ul{padding-left:1rem}ul.pagination{display:flex;justify-content:center}ul.pagination .page-item a{padding:1rem}.container{max-width:80rem;margin:0 auto}.book-brand{margin-top:0}.book-menu{flex:0 0 16rem;font-size:.875rem}.book-menu nav{width:16rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-menu a{color:#343a40}.book-menu a.active{color:#004ed0}.book-section-flat{margin-bottom:2rem}.book-section-flat>a,.book-section-flat>span{font-weight:600}.book-section-flat>ul{padding-left:0}.book-page{min-width:20rem;flex-grow:1;padding:1rem}.book-header{margin-bottom:1rem;display:none}.book-toc{flex:0 0 14rem;font-size:.75rem}.book-toc nav{width:14rem;padding:1rem;position:fixed;top:0;bottom:0;overflow-x:hidden;overflow-y:auto}.book-toc nav>ul>li{margin:0}.book-git-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-git-footer img{width:.875rem;vertical-align:bottom}.book-footer{display:flex;margin-top:1rem;font-size:.875rem;align-items:baseline}.book-footer img{width:.875rem;vertical-align:bottom}.book-posts{min-width:20rem;max-width:41rem;flex-grow:1;padding:1rem}.book-posts article{padding-bottom:1rem}aside nav,.book-page,.book-posts,.markdown{transition:.2s ease-in-out;transition-property:transform,margin-left,opacity;will-change:transform,margin-left}@media screen and (max-width:55rem){.book-toc{display:none}}@media screen and (max-width:41rem){.book-menu{margin-left:-16rem}.book-header{display:flex}#menu-control:checked+main .book-menu nav,#menu-control:checked+main .book-page,#menu-control:checked+main .book-posts{transform:translateX(16rem)}#menu-control:checked+main .book-header label{transform:rotate(90deg)}#menu-control:checked+main .markdown{opacity:.25}}@media screen and (min-width:80rem){.book-page,.book-posts,.book-menu nav,.book-toc nav{padding:2rem 1rem}}
|
|
@ -1 +1 @@
|
|||
{"Target":"book.min.10fb0ad8a0ad8e88648d3207b12be2833cd3df8a6e3b0955cbe49dc7fba8541c.css","MediaType":"text/css","Data":{"Integrity":"sha256-EPsK2KCtjohkjTIHsSvigzzT34puOwlVy+Sdx/uoVBw="}}
|
||||
{"Target":"book.min.fc91edf4e8d8e3b37416a60d5c7b6dea3f9f8385de9de634d1e8b44e9a1eece1.css","MediaType":"text/css","Data":{"Integrity":"sha256-/JHt9OjY47N0FqYNXHtt6j+fg4XeneY00ei0Tpoe7OE="}}
|
|
@ -6,7 +6,7 @@
|
|||
{{ partial "docs/html-head" . }}
|
||||
{{ partial "docs/inject/head" . }}
|
||||
</head>
|
||||
{{- $content := `
|
||||
{{ $content := `
|
||||
# Hugo Book Theme
|
||||
|
||||
This is a placeholder for home page.
|
||||
|
@ -14,7 +14,7 @@ You can override this page in:
|
|||
|
||||
- `/content/_index.md`
|
||||
- `/layouts/home.html`
|
||||
` -}}
|
||||
` }}
|
||||
<body>
|
||||
<main class="flex justify-center">
|
||||
<div class="book-page markdown">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="align-center book-git-footer {{ if not .GitInfo }}justify-end{{ else }}justify-between{{ end }}">
|
||||
{{ with .GitInfo }}
|
||||
<div>
|
||||
{{- $date := .AuthorDate.Local.Format (default "January 2, 2006" $.Site.Params.BookDateFormat) -}}
|
||||
{{ $date := .AuthorDate.Local.Format (default "January 2, 2006" $.Site.Params.BookDateFormat) }}
|
||||
<a href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='Last modified {{ $date }} by {{ .AuthorName }}' target="_blank" rel="noopener">
|
||||
<img src="{{ "svg/code-merge.svg" | relURL }}" /> {{ $date }}
|
||||
</a>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
{{- template "hrefhack" . -}}
|
||||
{{ template "hrefhack" . }}
|
||||
{{ with .Site.GetPage .Site.Params.BookMenuBundle }}
|
||||
{{- .Content -}}
|
||||
{{ end }}
|
||||
{{ if .Site.Params.BookEnableJS }}
|
||||
{{- template "jsmenu" . -}}
|
||||
{{ end }}
|
|
@ -1,47 +1,59 @@
|
|||
<!-- Put configured sections list to .Scratch -->
|
||||
{{ template "book-get-root-section" . }}
|
||||
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
||||
{{ if eq $bookSection "*" }}
|
||||
{{ .Scratch.Set "BookSections" .Site.Sections }}
|
||||
{{ else }}
|
||||
{{ $bookSections := where .Site.Sections "Section" $bookSection }}
|
||||
{{ .Scratch.Set "BookSections" $bookSections }}
|
||||
{{ end }}
|
||||
|
||||
{{- range .Scratch.Get "BookSections" -}}
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
|
||||
{{- end -}}
|
||||
|
||||
{{ define "book-section" }} <!-- Single section of menu (recursive) -->
|
||||
{{ $sections := .Scratch.Get "BookSections" }}
|
||||
{{/* If there is only one section to render then render its children, else render all sections */}}
|
||||
{{ if eq (len $sections) 1 }}
|
||||
{{ with index $sections 0 }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.Permalink) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<ul>
|
||||
{{ range .Section.Sections }}
|
||||
<li {{- if .Params.bookflatsection}} class="flat-section" {{ end }}>
|
||||
{{- if .Content -}}
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
{{- else -}}
|
||||
{{- template "title" . -}}
|
||||
{{- end -}}
|
||||
{{ range $sections }}
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ define "book-section" }}
|
||||
{{ with .Section }}
|
||||
<li {{ if .Params.bookFlatSection}} class="book-section-flat" {{ end }}>
|
||||
{{ if .Content }}
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
{{ else }}
|
||||
<span>{{ template "title" . }}</span>
|
||||
{{ end }}
|
||||
|
||||
{{ range .Section.Pages }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-section-children" }}
|
||||
{{ with .Section }}
|
||||
<ul>
|
||||
{{ range .Sections }}
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
{{ end }}
|
||||
{{ range .Pages }}
|
||||
<li>
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-page-link" }}
|
||||
{{- with .Page -}}
|
||||
<a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
|
||||
{{- template "title" . -}}
|
||||
</a>
|
||||
{{- end -}}
|
||||
{{ with .Page }}
|
||||
<a href="{{ .RelPermalink }}" {{ if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
|
||||
{{ template "title" . }}
|
||||
</a>
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-get-root-section" }}
|
||||
<!-- Complex logic to guess page title without .Title specified -->
|
||||
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
||||
{{ if eq $bookSection "*" }}
|
||||
{{ .Scratch.Set "BookSections" .Site.Sections }}
|
||||
{{ else }}
|
||||
{{ $bookSections := where .Site.Sections "Section" $bookSection }}
|
||||
{{ .Scratch.Set "BookSections" $bookSections }}
|
||||
{{ end }}
|
||||
{{ end }}
|
|
@ -10,3 +10,7 @@
|
|||
|
||||
{{ partial "docs/inject/menu-after" . }}
|
||||
</nav>
|
||||
|
||||
{{ if .Site.Params.BookEnableJS }}
|
||||
{{ template "jsmenu" . }}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
{{/*These templates contains some more complex logic and shared between partials*/}}
|
||||
{{- define "title" -}}
|
||||
{{- if and .File .Pages -}}
|
||||
{{ define "title" }}
|
||||
{{ if and .File .Pages }}
|
||||
{{ $sections := split (trim .File.Dir "/") "/" }}
|
||||
{{ $title := index ($sections | last 1) 0 | humanize | title }}
|
||||
{{- default $title .Title -}}
|
||||
{{- else if .File -}}
|
||||
{{ $title := .File | humanize | title }}
|
||||
{{- default $title .Title -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ default $title .Title }}
|
||||
{{ else if .File }}
|
||||
{{ $title := .File.BaseFileName | humanize | title }}
|
||||
{{ default $title .Title }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{- define "hrefhack" -}}
|
||||
{{ define "hrefhack" }}
|
||||
{{ $attrEq := "$=" }}
|
||||
{{ $attrVal := .RelPermalink }}
|
||||
{{ if eq .RelPermalink "/" }}
|
||||
|
@ -23,17 +23,16 @@
|
|||
color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }};
|
||||
}
|
||||
</style>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
|
||||
{{- define "jsmenu" -}}
|
||||
{{ define "jsmenu" }}
|
||||
<script>
|
||||
(function() {
|
||||
var menu = document.querySelector('aside.book-menu nav')
|
||||
addEventListener('beforeunload', function(event) {
|
||||
localStorage.setItem('menu.scrollTop', menu.scrollTop)
|
||||
});
|
||||
|
||||
menu.scrollTop = localStorage.getItem('menu.scrollTop')
|
||||
})()
|
||||
</script>
|
||||
{{- end -}}
|
||||
{{ end }}
|
|
@ -1,15 +1,15 @@
|
|||
{{ define "main" }}
|
||||
{{- $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat -}}
|
||||
{{ $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat }}
|
||||
{{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }}
|
||||
{{ range sort .Paginator.Pages }}
|
||||
<article>
|
||||
<article class="markdown">
|
||||
<h2>
|
||||
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||
</h2>
|
||||
<h5>
|
||||
<strong>{{ .Date.Format $dateFormat }}</strong>
|
||||
</h5>
|
||||
<p class="markdown">
|
||||
<p>
|
||||
{{- .Summary -}}
|
||||
{{ if .Truncated }}
|
||||
<a href="{{ .RelPermalink }}">...</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{ define "main" }}
|
||||
{{- $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat -}}
|
||||
<header>
|
||||
{{ $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat }}
|
||||
<header class="markdown">
|
||||
<h1>{{ .Title }}</h1>
|
||||
<h5>
|
||||
<strong>{{ .Date.Format $dateFormat }}</strong>
|
||||
|
|
Loading…
Reference in a new issue