Skip to content

Commit

Permalink
Merge pull request #865 from flynnduism/custom-menu
Browse files Browse the repository at this point in the history
[docs] adds custom menu for docs
  • Loading branch information
flynnduism committed Apr 1, 2019
2 parents deca99b + dd16982 commit 8a8f7b0
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 62 deletions.
150 changes: 148 additions & 2 deletions docs/config.toml
Expand Up @@ -8,8 +8,154 @@ relativeURLs = "false"
title = "Brigade"
description = "Brigade - Event-driven scripting for Kubernetes."

# top navigation
# (side nav is auto generated from content dir)
# main docs 'index' menu on left
[[menu.index]]
name = "Home"
url = "https://brigade.sh"
weight = 10
[[menu.index]]
name = "Getting Started"
url = "/intro/"
weight = 20
identifier = "intro"
[[menu.index]]
name = "Overview"
url = "/intro/overview/"
weight = 21
parent = "intro"
[[menu.index]]
name = "Installing Brigade"
url = "/intro/install/"
weight = 22
parent = "intro"
[[menu.index]]
name = "Tutorial 1: Writing a CI pipeline"
url = "/intro/tutorial01/"
weight = 23
parent = "intro"
[[menu.index]]
name = "Tutorial 2: Setup GitHub"
url = "/intro/tutorial02/"
weight = 24
parent = "intro"
[[menu.index]]
name = "Tutorial 3: Projects & Events"
url = "/intro/tutorial03/"
weight = 25
parent = "intro"
[[menu.index]]
name = "Tutorial 4: Writing a Test"
url = "/intro/tutorial04/"
weight = 26
parent = "intro"
[[menu.index]]
name = "Tutorial 5: Writing Efficient Pipelines"
url = "/intro/writing-efficient-pipelines/"
weight = 27
parent = "intro"
[[menu.index]]
name = "What to Read Next"
url = "/intro/readnext/"
weight = 28
parent = "intro"
[[menu.index]]
name = "Topic Guides"
url = "/topics/"
weight = 30
identifier = "topics"
[[menu.index]]
name = "Advanced Scripting Guide"
url = "/topics/scripting_advanced/"
weight = 31
parent = "topics"
[[menu.index]]
name = "Container Registry Integration"
url = "/topics/dockerhub/"
weight = 32
parent = "topics"
[[menu.index]]
name = "Dependencies"
url = "/topics/dependencies/"
weight = 33
parent = "topics"
[[menu.index]]
name = "Design"
url = "/topics/design/"
weight = 34
parent = "topics"
[[menu.index]]
name = "Developer Guide"
url = "/topics/developers/"
weight = 35
parent = "topics"
[[menu.index]]
name = "Gateways"
url = "/topics/gateways/"
weight = 36
parent = "topics"
[[menu.index]]
name = "Genric Gateway"
url = "/topics/genericgateway/"
weight = 37
parent = "topics"
[[menu.index]]
name = "GitHub Integration"
url = "/topics/github/"
weight = 38
parent = "topics"
[[menu.index]]
name = "Ingress"
url = "/topics/ingress/"
weight = 39
parent = "topics"
[[menu.index]]
name = "Projects"
url = "/topics/projects/"
weight = 40
parent = "topics"
[[menu.index]]
name = "Releasing Brigade"
url = "/topics/releasing/"
weight = 41
parent = "topics"
[[menu.index]]
name = "Scripting Guide"
url = "/topics/scripting/"
weight = 42
parent = "topics"
[[menu.index]]
name = "Secret Management"
url = "/topics/secrets/"
weight = 43
parent = "topics"
[[menu.index]]
name = "Securing Brigade"
url = "/topics/security/"
weight = 44
parent = "topics"
[[menu.index]]
name = "Storage"
url = "/topics/storage/"
weight = 45
parent = "topics"
[[menu.index]]
name = "Testing"
url = "/topics/testing/"
weight = 46
parent = "topics"
[[menu.index]]
name = "The Brigade.js API"
url = "/topics/javascript/"
weight = 47
parent = "topics"
[[menu.index]]
name = "Workers"
url = "/topics/workers/"
weight = 48
parent = "topics"


# top navigation - project links
[[menu.main]]
name = "Docs"
url = "https://docs.brigade.sh"
Expand Down
75 changes: 19 additions & 56 deletions docs/themes/techdoc-brigade/layouts/partials/menu.html
@@ -1,58 +1,21 @@
{{$currentNode := .}}
{{ $currentPage := . }}
{{- if .Site.Menus.index -}}
<nav>
<ul>
<li class="{{ if .IsHome }}active{{ end }}"><a href="{{ .Site.BaseURL }}">Home</a></li>
{{- if eq .Site.Params.ordersectionsby "title" -}}
{{- range .Site.Home.Sections.ByTitle -}}
{{template "menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- else -}}
{{- range .Site.Home.Sections.ByWeight -}}
{{template "menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- end}}
</ul>
</nav>

{{define "menu"}}
{{- $currentNode := .currentnode -}}
{{ with .sect }}
{{ if .IsSection }}
{{ if in .Site.Params.menu_exclusion .Section }}
{{- else -}}
{{- safeHTML .Params.head -}}
<li class="{{ if .IsAncestor $currentNode }}parent{{ end }}{{ if eq .UniqueID $currentNode.UniqueID }} active{{ end }}{{ if .Params.alwaysopen }} parent{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}</a>
{{- $numberOfPages := (add (len .Pages) (len .Sections)) -}}
{{if ne $numberOfPages 0}}
<ul class="{{ if .IsAncestor $currentNode }}sub-menu{{ end }}">
{{- .Scratch.Set "pages" .Pages -}}
{{- if .Sections -}}
{{- .Scratch.Set "pages" (.Pages | union .Sections) -}}
{{- end -}}
{{- $pages := (.Scratch.Get "pages") -}}
{{- if eq .Site.Params.ordersectionsby "title" -}}
{{- range $pages.ByTitle -}}
{{- if and .Params.hidden (not $.showhidden) -}}
{{- else -}}
{{template "menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
{{- end -}}
{{- else -}}
{{- range $pages.ByWeight -}}
{{- if and .Params.hidden (not $.showhidden) -}}
{{- else -}}
{{template "menu" dict "sect" . "currentnode" $currentNode}}
{{- end -}}
<ul>
{{- range .Site.Menus.index.ByWeight -}}
{{ if .HasChildren -}}
<li class="parent{{ if $currentPage.HasMenuCurrent "index" . }} active{{ end }}"><a href="{{ .URL | absURL }}">{{- .Name -}} <i class="fas fa-angle-right"></i></a>

<ul class="sub-menu">
{{ range .Children -}}
<li class="child{{ if $currentPage.HasMenuCurrent "index" . }} active{{ end }}"><a href="{{ .URL | absURL }}">{{ .Name }}</a></li>
{{ end -}}
</ul>
</li>
{{- else }}
<li{{ if $currentPage.HasMenuCurrent "index" . }} class="active"{{ end }}><a href="{{ .URL | absURL }}">{{- .Name -}}</a></li>
{{- end -}}
{{- end}}
</ul>
{{end}}
</li>
{{- end -}}
{{- else -}}
{{- if not .Params.Hidden -}}
<li class="{{ if eq .UniqueID $currentNode.UniqueID }}active{{ end }}"><a href="{{ .URL }}">{{ safeHTML .Params.Pre }}{{ .Title }}{{ safeHTML .Params.Post }}</a></li>
{{- end -}}
{{ end -}}
{{ end -}}
{{ end }}
{{- end -}}
</ul>
</nav>
{{- end }}
8 changes: 4 additions & 4 deletions docs/themes/techdoc-brigade/layouts/partials/sidebar.html
@@ -1,6 +1,6 @@
<div class="sidebar">
{{- partial "menu.html" . -}}
<div class="sidebar-footer">
{{- partial "sidebar-footer.html" . -}}
</div>
{{- partial "menu.html" . -}}
<div class="sidebar-footer">
{{- partial "sidebar-footer.html" . -}}
</div>
</div>

0 comments on commit 8a8f7b0

Please sign in to comment.