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"] images: ["{{ .Name | urlize }}.jpg"]
contributors: [] 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 }} lastmod: {{ .Date }}
draft: true draft: true
images: [] images: []
menu: menu:
docs: docs:
parent: "" parent: ""
weight: 999 weight: 999
toc: true 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" identifier = "help"
url = "/docs/help/" url = "/docs/help/"
[[docs]] # [[docs]]
# name = "Lorem"
# weight = 70
# identifier = "lorem"
# url = "/docs/lorem/"
[[guide]]
name = "Lorem" name = "Lorem"
weight = 70 weight = 10
identifier = "lorem" identifier = "lorem"
url = "/docs/lorem/" url = "/guide/lorem/"
[[tutorial]]
name = "Lorem"
weight = 10
identifier = "lorem"
url = "/tutorial/lorem/"
[[main]] [[main]]
name = "Docs" name = "Docs"
@ -22,6 +34,21 @@
# url = "/docs/1.0/prologue/introduction/" # url = "/docs/1.0/prologue/introduction/"
weight = 10 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]] [[main]]
name = "Blog" name = "Blog"
url = "/blog/" url = "/blog/"

View File

@ -92,4 +92,3 @@ lastMod = false
[menu.section] [menu.section]
auto = true auto = true
collapsibleSidebar = 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: "" description: ""
lead: ""
date: 2022-01-25T14:40:56+01:00 date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00 lastmod: 2022-01-25T14:40:56+01:00
draft: false draft: false
images: [] images: []
type: docs
--- ---

View File

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

View File

@ -1,8 +1,19 @@
--- ---
title: "Ipsum" title: "Ipsum"
description: "" description: ""
lead: ""
date: 2022-01-25T14:41:39+01:00 date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00 lastmod: 2022-01-25T14:41:39+01:00
draft: false draft: false
images: [] 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> <h3 class="h6 text-uppercase mb-3 d-md-none">Main</h3>
<ul class="nav flex-column flex-md-row ms-md-n3"> <ul class="nav flex-column flex-md-row ms-md-n3">
{{- $current := . -}} {{- $current := . -}}
{{- $section := $current.Section -}}
{{ range .Site.Menus.main -}} {{ range .Site.Menus.main -}}
{{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}} {{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
{{- $active = or $active (eq .Name $current.Title) -}} {{- $active = or $active (eq .Name $current.Title) -}}
{{- $active = or $active (and (eq .Name "Docs") (eq $current.Section "docs")) -}} {{- $active = or $active (and (eq .Name ($section | humanize)) (eq $current.Section $section)) -}}
{{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "authors")) -}} {{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "contributors")) -}}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a> <a class="nav-link ps-0 py-1{{ if $active }} active{{ end }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li> </li>

View File

@ -1,7 +1,8 @@
<!-- Auto collapsible section menu --> <!-- Auto collapsible section menu -->
<ul class="list-unstyled collapsible-sidebar"> <ul class="list-unstyled collapsible-sidebar">
{{ $currentPage := . -}} {{ $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 }} {{ range .Sections.Reverse }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }} {{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="mb-1"> <li class="mb-1">

View File

@ -1,6 +1,7 @@
<!-- Auto default section menu --> <!-- Auto default section menu -->
{{ $currentPage := . -}} {{ $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 }} {{ range .Sections.Reverse }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }} {{ $active := in $currentPage.RelPermalink .RelPermalink }}
<h3 class="h6 text-uppercase mb-2">{{ .Title }}</h3> <h3 class="h6 text-uppercase mb-2">{{ .Title }}</h3>

View File

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

View File

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