Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new docs tree — with a single command 🤖 #637

Merged
merged 3 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions archetypes/blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
4 changes: 1 addition & 3 deletions archetypes/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}" >}}
4 changes: 3 additions & 1 deletion content/en/tutorial/_index.md → archetypes/docs/_index.md
Original file line number Diff line number Diff line change
@@ -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
---
Original file line number Diff line number Diff line change
@@ -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
---
Original file line number Diff line number Diff line change
@@ -1,8 +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
---
23 changes: 20 additions & 3 deletions config/_default/menus/menus.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,35 @@
identifier = "help"
url = "/docs/help/"

[[docs]]
# [[docs]]
# name = "Lorem"
# weight = 70
# identifier = "lorem"
# url = "/docs/lorem/"

[[guide]]
name = "Lorem"
weight = 10
identifier = "lorem"
url = "/guide/lorem/"

[[tutorial]]
name = "Lorem"
weight = 70
weight = 10
identifier = "lorem"
url = "/docs/lorem/"
url = "/tutorial/lorem/"

[[main]]
name = "Docs"
url = "/docs/prologue/introduction/"
# url = "/docs/1.0/prologue/introduction/"
weight = 10

# [[main]]
# name = "Tutorial"
# url = "/tutorial/lorem/ipsum/"
# weight = 15

[[main]]
name = "Blog"
url = "/blog/"
Expand Down
1 change: 0 additions & 1 deletion config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ lastMod = false
[menu.section]
auto = true
collapsibleSidebar = true
mainSections = ["docs"]
2 changes: 1 addition & 1 deletion layouts/docs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="row justify-content-center">
<div class="col-md-12 col-lg-10 col-xl-8">
<article>
<h1 class="text-center">{{ .Title }}</h1>
<h1 class="text-center">{{ if eq .CurrentSection .FirstSection }}{{ .Section | humanize }}{{ else }}{{ .Title }}{{ end }}</h1>
<div class="text-center">{{ .Content }}</div>
<div class="card-list">
{{ $currentSection := .CurrentSection }}
Expand Down
24 changes: 22 additions & 2 deletions layouts/partials/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ <h2 class="h5 offcanvas-title ps-2" id="offcanvasDoksLabel"><a class="text-dark"
<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>
Expand Down Expand Up @@ -128,6 +129,25 @@ <h3 class="h6 text-uppercase mb-3 d-md-none">Socials</h3>
</div>
</nav>

<div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}">
<aside class="doks-sidebar">
<nav id="doks-docs-nav" class="collapse d-lg-none" aria-label="Tertiary navigation">
{{ partial "sidebar/docs-menu.html" . }}
</nav>
</aside>
</div>

{{ else -}}
<nav class="doks-subnavbar py-2 sticky-lg-top d-lg-none" aria-label="Secondary navigation">
<div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }} d-flex align-items-md-center">
<span class="navbar-text ms-0">{{ .Section | humanize }}</span>
<button class="btn doks-sidebar-toggle d-lg-none ms-auto order-3 collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#doks-docs-nav" aria-controls="doks-docs-nav" aria-expanded="false" aria-label="Toggle documentation navigation">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="doks doks-expand" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Expand</title><polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" class="doks doks-collapse" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><title>Collapse</title><polyline points="17 11 12 6 7 11"></polyline><polyline points="17 18 12 13 7 18"></polyline></svg>
</button>
</div>
</nav>

<div class="container-{{ if .Site.Params.options.fullWidth }}fluid{{ else }}xxl{{ end }}">
<aside class="doks-sidebar">
<nav id="doks-docs-nav" class="collapse d-lg-none" aria-label="Tertiary navigation">
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/main/breadcrumb.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ with .Parent -}}
{{ partial "main/breadcrumb.html" . -}}
<li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ if .IsHome }}Home{{ else }}{{ .Title }}{{ end }}</a></li>
<li class="breadcrumb-item"><a href="{{ .RelPermalink }}">{{ if .IsHome }}Home{{ else if eq .CurrentSection .FirstSection }}{{ .Section | humanize }}{{ else }}{{ .Title }}{{ end }}</a></li>
{{ end -}}
3 changes: 2 additions & 1 deletion layouts/partials/sidebar/auto-collapsible-menu.html
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/sidebar/auto-default-menu.html
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
11 changes: 6 additions & 5 deletions layouts/partials/sidebar/manual-collapsible-menu.html
Original file line number Diff line number Diff line change
@@ -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 }}">
Expand Down Expand Up @@ -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 -}}
Expand All @@ -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 -}}
Expand All @@ -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 -}}
Expand Down
9 changes: 5 additions & 4 deletions layouts/partials/sidebar/manual-default-menu.html
Original file line number Diff line number Diff line change
@@ -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">
Expand All @@ -15,22 +16,22 @@ <h5 class="h6 text-uppercase mt-2 mb-2">{{ .Name }}</h5>
{{ 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 -}}
{{ 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 -}}
Expand Down