feat: add auto new docs tree

This commit is contained in:
Henk Verlinde 2022-01-28 13:52:51 +01:00
parent 4b3e21abb5
commit f7bb574a9b
21 changed files with 174 additions and 23 deletions

View File

@ -9,5 +9,3 @@ weight: 50
images: ["{{ .Name | urlize }}.jpg"]
contributors: []
---
{{< img src="{{ .Name | urlize }}.jpg" alt="{{ replace .Name "-" " " | title }}" caption="{{ replace .Name "-" " " | title }}" class="wide" >}}

View File

@ -6,11 +6,9 @@ date: {{ .Date }}
lastmod: {{ .Date }}
draft: true
images: []
menu:
menu:
docs:
parent: ""
weight: 999
toc: true
---
{{< img src="{{ .Name | urlize }}.jpg" alt="{{ replace .Name "-" " " | title }}" caption="{{ replace .Name "-" " " | title }}" >}}

10
archetypes/docs/_index.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "Docs"
description: ""
lead: ""
date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,10 @@
---
title: "Lorem"
description: ""
lead: ""
date: 2022-01-25T14:41:21+01:00
lastmod: 2022-01-25T14:41:21+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,15 @@
---
title: "Ipsum"
description: ""
lead: ""
date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00
draft: false
images: []
type: docs
menu:
{{ .Section }}:
parent: "lorem"
weight: 100
toc: true
---

View File

@ -10,11 +10,23 @@
identifier = "help"
url = "/docs/help/"
[[docs]]
# [[docs]]
# name = "Lorem"
# weight = 70
# identifier = "lorem"
# url = "/docs/lorem/"
[[guide]]
name = "Lorem"
weight = 70
weight = 10
identifier = "lorem"
url = "/docs/lorem/"
url = "/guide/lorem/"
[[tutorial]]
name = "Lorem"
weight = 10
identifier = "lorem"
url = "/tutorial/lorem/"
[[main]]
name = "Docs"
@ -22,6 +34,21 @@
# url = "/docs/1.0/prologue/introduction/"
weight = 10
[[main]]
name = "Guide"
url = "/guide/lorem/ipsum/"
weight = 11
[[main]]
name = "Tutorial"
url = "/tutorial/lorem/ipsum/"
weight = 12
[[main]]
name = "Hints"
url = "/hints/lorem/ipsum/"
weight = 13
[[main]]
name = "Blog"
url = "/blog/"

View File

@ -92,4 +92,3 @@ lastMod = false
[menu.section]
auto = true
collapsibleSidebar = true
mainSections = ["docs"]

View File

@ -0,0 +1,10 @@
---
title: "Docs"
description: ""
lead: ""
date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,10 @@
---
title: "Lorem"
description: ""
lead: ""
date: 2022-01-25T14:41:21+01:00
lastmod: 2022-01-25T14:41:21+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,19 @@
---
title: "Ipsum"
description: ""
lead: ""
date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00
draft: false
images: []
type: docs
menu:
guide:
parent: "lorem"
weight: 100
toc: true
---
## Intro
Welcome to the Guide!

View File

@ -0,0 +1,10 @@
---
title: "Docs"
description: ""
lead: ""
date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,10 @@
---
title: "Lorem"
description: ""
lead: ""
date: 2022-01-25T14:41:21+01:00
lastmod: 2022-01-25T14:41:21+01:00
draft: false
images: []
type: docs
---

View File

@ -0,0 +1,15 @@
---
title: "Ipsum"
description: ""
lead: ""
date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00
draft: false
images: []
type: docs
menu:
hints:
parent: "lorem"
weight: 100
toc: true
---

View File

@ -1,8 +1,10 @@
---
title: "Tutorial"
title: "Docs"
description: ""
lead: ""
date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00
draft: false
images: []
type: docs
---

View File

@ -1,8 +1,10 @@
---
title: "Lorem"
description: ""
lead: ""
date: 2022-01-25T14:41:21+01:00
lastmod: 2022-01-25T14:41:21+01:00
draft: false
images: []
type: docs
---

View File

@ -1,8 +1,19 @@
---
title: "Ipsum"
description: ""
lead: ""
date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00
draft: false
images: []
type: docs
menu:
tutorial:
parent: "lorem"
weight: 100
toc: true
---
## Intro
Welcome to the Tutorial!

View File

@ -28,11 +28,12 @@
<h3 class="h6 text-uppercase mb-3 d-md-none">Main</h3>
<ul class="nav flex-column flex-md-row ms-md-n3">
{{- $current := . -}}
{{- $section := $current.Section -}}
{{ range .Site.Menus.main -}}
{{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
{{- $active = or $active (eq .Name $current.Title) -}}
{{- $active = or $active (and (eq .Name "Docs") (eq $current.Section "docs")) -}}
{{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "authors")) -}}
{{- $active = or $active (and (eq .Name ($section | humanize)) (eq $current.Section $section)) -}}
{{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "contributors")) -}}
<li class="nav-item">
<a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>

View File

@ -1,7 +1,8 @@
<!-- Auto collapsible section menu -->
<ul class="list-unstyled collapsible-sidebar">
{{ $currentPage := . -}}
{{ range (where .Site.Sections "Section" "in" site.Params.menu.section.mainSections) }}
{{ $section := $currentPage.Section -}}
{{ range (where .Site.Sections "Section" "in" $section) }}
{{ range .Sections.Reverse }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="mb-1">

View File

@ -1,6 +1,7 @@
<!-- Auto default section menu -->
{{ $currentPage := . -}}
{{ range (where .Site.Sections "Section" "in" site.Params.menu.section.mainSections) }}
{{ $section := $currentPage.Section -}}
{{ range (where .Site.Sections "Section" "in" $section) }}
{{ range .Sections.Reverse }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<h3 class="h6 text-uppercase mb-2">{{ .Title }}</h3>

View File

@ -1,8 +1,9 @@
<!-- Manual collapsible section menu -->
<ul class="list-unstyled collapsible-sidebar">
{{ $currentPage := . -}}
{{ range $index, $element := .Site.Menus.docs -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{ $section := $currentPage.Section -}}
{{ range (index .Site.Menus $section) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ .Identifier }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}">
@ -30,7 +31,7 @@
<div class="collapse{{ if $active }} show{{ end }}" id="section-{{ .Identifier }}">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
{{ range .Children -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}
@ -39,7 +40,7 @@
{{ end -}}
</li>
{{ else -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}
@ -49,7 +50,7 @@
{{ end -}}
</li>
{{ else -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}

View File

@ -1,6 +1,7 @@
<!-- Manual default section menu -->
{{ $currentPage := . -}}
{{ range .Site.Menus.docs -}}
{{ $section := $currentPage.Section -}}
{{ range (index .Site.Menus $section) -}}
<h3 class="h6 text-uppercase mb-2">{{ .Name }}</h3>
{{ if .HasChildren -}}
<ul class="list-unstyled">
@ -15,14 +16,14 @@
{{ if .HasChildren -}}
<ul class="list-unstyled ms-3">
{{ range .Children -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}
</ul>
{{ end -}}
{{ else -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}
@ -30,7 +31,7 @@
</ul>
{{ end -}}
{{ else -}}
{{- $active := or ($currentPage.IsMenuCurrent "docs" .) ($currentPage.HasMenuCurrent "docs" .) -}}
{{- $active := or ($currentPage.IsMenuCurrent $section .) ($currentPage.HasMenuCurrent $section .) -}}
{{- $active = or $active (eq $currentPage.Section .Identifier) -}}
<li><a class="docs-link{{ if $active }} active{{ end }}" href="{{ .URL | relURL }}">{{ .Name }}</a></li>
{{ end -}}