mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-31 08:57:15 +00:00
Added menu generation from defenition on content.md files, selectable using params .createFromSiteMenusMain on toml file. (#5)
Fixes #2
This commit is contained in:
parent
de8584e890
commit
64012f31af
2 changed files with 66 additions and 9 deletions
|
@ -48,6 +48,20 @@
|
||||||
{{ if and (not .Params.chapter) (.Params.toc) }}
|
{{ if and (not .Params.chapter) (.Params.toc) }}
|
||||||
<span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
|
<span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ if $page.Site.Params.createFromSiteMenusMain}}
|
||||||
|
{{ $type := .Params.menu.main.parent }}
|
||||||
|
{{ $relLink := .RelPermalink }}
|
||||||
|
{{ range $name , $value := .Site.Menus.main }}
|
||||||
|
|
||||||
|
{{ if eq $value.Identifier $type }}
|
||||||
|
{{ if ne $relLink $value.URL }}
|
||||||
|
<a href="{{ $value.URL }}" itemprop="url"><span itemprop="title"> <b>{{ $value.Name }}</b></span></a> <i class="fa fa-angle-right"></i>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{else}} <!-- use current method as default-->
|
||||||
|
|
||||||
{{ $type := .Type }}
|
{{ $type := .Type }}
|
||||||
{{ $relLink := .RelPermalink }}
|
{{ $relLink := .RelPermalink }}
|
||||||
{{ range $name , $value := .Site.Sections }}
|
{{ range $name , $value := .Site.Sections }}
|
||||||
|
@ -58,6 +72,8 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{ with .Title }}<span itemprop="title"> {{ . }}</span>{{ end }}
|
{{ with .Title }}<span itemprop="title"> {{ . }}</span>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ if .Params.toc }}
|
{{ if .Params.toc }}
|
||||||
|
|
|
@ -16,6 +16,42 @@
|
||||||
<div class="highlightable">
|
<div class="highlightable">
|
||||||
<ul class="topics">
|
<ul class="topics">
|
||||||
{{ $page := . }}
|
{{ $page := . }}
|
||||||
|
|
||||||
|
{{ if $page.Site.Params.createFromSiteMenusMain}}
|
||||||
|
{{ range .Site.Menus.main }}
|
||||||
|
<li class="dd-item {{ if eq $page.RelPermalink .URL }}active{{ end }} {{if in $page.RelPermalink .URL }}parent{{ end }}" data-nav-id="{{.URL}}">
|
||||||
|
<a href="{{.URL}}">
|
||||||
|
<span>{{ .Pre }} {{ .Name }} {{ if $page.Site.Params.showVisitedLinks}} <i class="fa fa-check read-icon"> {{ end }} </i> </span>
|
||||||
|
</a>
|
||||||
|
{{ if .HasChildren }}
|
||||||
|
<ul>
|
||||||
|
{{ range $lvl2 := .Children}}
|
||||||
|
<li class="dd-item {{ if eq $page.RelPermalink $lvl2.URL }}active{{ end }}" data-nav-id="{{$lvl2.URL}}">
|
||||||
|
<a href="{{$lvl2.URL}}">
|
||||||
|
<span> {{ $lvl2.Pre }} {{ $lvl2.Name }} {{ if $page.Site.Params.showVisitedLinks}} <i class="fa fa-check read-icon"></i> {{ end }} </span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{{ if $lvl2.HasChildren }}
|
||||||
|
<!-- if children has children 3rd level -->
|
||||||
|
<ul>
|
||||||
|
{{ range $lvl3 := $lvl2.Children}}
|
||||||
|
<li class="dd-item {{ if eq $page.RelPermalink $lvl3.URL }}active{{ end }}" data-nav-id="{{$lvl3.URL}}">
|
||||||
|
<a href="{{$lvl3.URL}}">
|
||||||
|
<span>{{ $lvl3.Pre }} {{ $lvl3.Name }} {{ if $page.Site.Params.showVisitedLinks}} <i class="fa fa-check read-icon"></i> {{ end }} </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
{{ end }}
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
{{ end }}
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
{{else}}
|
||||||
|
<!-- Use default method, create menu from folder structure -->
|
||||||
|
|
||||||
{{ range $key , $value := .Site.Sections }}
|
{{ range $key , $value := .Site.Sections }}
|
||||||
{{ if ne $key "" }}
|
{{ if ne $key "" }}
|
||||||
{{ $first := (index $value 0).Page }}
|
{{ $first := (index $value 0).Page }}
|
||||||
|
@ -48,6 +84,11 @@
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
{{ if .Site.Params.showVisitedLinks}}
|
{{ if .Site.Params.showVisitedLinks}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue