Backwards compatibility

This commit is contained in:
Nikolay Yakimov 2017-03-14 02:10:33 +03:00
parent f238cdbc16
commit 79107d2e75
No known key found for this signature in database
GPG key ID: 8E9303568F9B9650
4 changed files with 37 additions and 17 deletions

View file

@ -1,3 +1,5 @@
{{ if .Content }}
{{ partial "header.html" . }}
{{ .Content }}
{{ partial "footer.html" . }}
{{ end }}

View file

@ -1,17 +1,27 @@
{{ if eq .Kind "section" }}
{{ $isChapter := or (eq .Kind "section") (.Params.chapter)}}
{{ if $isChapter }}
</div> <!-- end chapter-->
{{ end }}
</div>
</div>
{{ $.Scratch.Set "_sectionpages" (slice) }}
{{ range $sname, $spages := .Site.Sections }}
{{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }}
{{ if $.Site.Params.menu }}
{{ range $sname := $.Site.Params.menu }}
{{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }}
{{ end }}
{{ else }}
{{ range $sname, $spages := .Site.Sections }}
{{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }}
{{ end }}
{{ $.Scratch.Set "_sectionpages" (sort ($.Scratch.Get "_sectionpages") "Weight") }}
{{ end }}
{{ $.Scratch.Set "_allpages" (slice) }}
{{ range sort ($.Scratch.Get "_sectionpages") "Weight" }}
{{ $.Scratch.Add "_allpages" . }}
{{ range $.Scratch.Get "_sectionpages" }}
{{ if .Content }}
{{ $.Scratch.Add "_allpages" . }}
{{ end }}
{{ range index $.Site.Sections .Section }}
{{ $.Scratch.Add "_allpages" .Page }}
{{ end }}

View file

@ -22,6 +22,7 @@
{{ partial "style.html" . }}
</head>
<body class="" data-url="{{ .RelPermalink }}">
{{ $isChapter := or (eq .Kind "section") (.Params.chapter)}}
{{ partial "menu.html" . }}
<section id="body">
<div id="overlay"></div>
@ -47,7 +48,7 @@
<i class="fa fa-bars"></i>
</a>
</span>
{{ if and (ne .Kind "section") (.Params.toc) }}
{{ if and (not $isChapter) (.Params.toc) }}
<span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
{{ end }}
{{ $type := .Type }}
@ -67,10 +68,10 @@
{{ end }}
</div>
{{ if eq .Kind "section" }}
{{ if $isChapter }}
<div id="chapter">
{{ end }}
<div id="body-inner">
{{ if ne .Kind "section" }}
{{ if not $isChapter }}
<h1>{{.Title}}</h1>
{{ end }}

View file

@ -12,27 +12,34 @@
<div class="highlightable">
<ul class="topics">
{{ $page := . }}
{{ $.Scratch.Set "_pages" (slice) }}
{{ range $key, $value := .Site.Sections }}
{{ $.Scratch.Add "_pages" ($.Site.GetPage "section" $key) }}
{{ end }}
{{ $.Scratch.Set "menuItems" (slice)}}
{{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }}
{{ $.Scratch.Add "menuItems" $value.Section }}
{{ if $.Site.Params.menu }}
{{ $.Scratch.Set "menuItems" $.Site.Params.menu }}
{{ else }}
{{ $.Scratch.Set "_pages" (slice) }}
{{ range $key, $value := .Site.Sections }}
{{ $.Scratch.Add "_pages" ($.Site.GetPage "section" $key) }}
{{ end }}
{{ $.Scratch.Set "menuItems" (slice)}}
{{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }}
{{ $.Scratch.Add "menuItems" $value.Section }}
{{ end }}
{{ end }}
{{ $menuItems := $.Scratch.Get "menuItems" }}
{{ range $i, $key := $menuItems }}
{{ if ne $key "" }}
{{ $value := (index $page.Site.Sections $key) }}
{{ $.Scratch.Set "_value" $value }}
{{ with $index := $.Site.GetPage "section" $key }}
{{ if .Title }}
{{ if .Content }}
{{ $.Scratch.Set "first" $index }}
{{ else }}
{{ $.Scratch.Set (index $value 0).Page }}
{{ $.Scratch.Set "first" (index $value 0).Page }}
{{ $.Scratch.Set "_value" (after 1 $value) }}
{{ end }}
{{ end }}
{{ $first := $.Scratch.Get "first" }}
{{ $value := $.Scratch.Get "_value" }}
<li class="dd-item {{ if eq $page.RelPermalink $first.RelPermalink }}active{{ end }} {{if in $page.RelPermalink $first.RelPermalink }}parent{{ end }}" data-nav-id="{{ $first.RelPermalink }}">
<a href="{{ $first.RelPermalink }}">