Rework of main template, adds options for more fine customisation

This commit is contained in:
Alex Shpak
2020-01-24 00:07:47 +01:00
parent 2acd6ab280
commit ba5d38ad44
31 changed files with 161 additions and 110 deletions
+53 -8
View File
@@ -7,24 +7,69 @@
</head>
<body>
<input type="checkbox" class="hidden" id="toc-control" />
<input type="checkbox" class="hidden" id="menu-control" />
<main class="container">
{{ template "toc" . }}
<main class="container flex">
<aside class="book-menu">
{{ template "menu" . }} <!-- Left menu Content -->
</aside>
<div class="book-page">
{{ partial "docs/mobile-header" . }}
{{ template "main" . }}
{{ partial "docs/footer" . }}
<header class="book-header">
{{ template "header" . }} <!-- Mobile layout header -->
</header>
{{ template "main" . }} <!-- Page Content -->
<footer class="book-footer">
{{ template "footer" . }} <!-- Footer under page content -->
{{ template "comments" . }} <!-- Comments block -->
</footer>
{{ partial "docs/inject/footer" . }}
</div>
<aside class="book-menu fixed">
{{ partial "docs/menu" . }}
{{ if default true (default .Site.Params.BookToC .Params.BookToC) }}
<aside class="book-toc">
{{ template "toc" . }} <!-- Table of Contents -->
</aside>
{{ end }}
</main>
{{ partial "docs/inject/body" . }}
</body>
</html>
{{ define "menu" }}
{{ partial "docs/menu" . }}
{{ end }}
{{ define "header" }}
{{ partial "docs/header" . }}
{{ if default true (default .Site.Params.BookToC .Params.BookToC) }}
<input type="checkbox" class="hidden" id="toc-control" />
<aside class="hidden clearfix">
{{ template "toc" . }}
</aside>
{{ end }}
{{ end }}
{{ define "footer" }}
{{ partial "docs/footer" . }}
{{ end }}
{{ define "comments" }}
{{ if and .Content (default true (default .Site.Params.BookComments .Params.BookComments)) }}
<div class="book-comments">
{{- partial "docs/comments" . -}}
</div>
{{ end }}
{{ end }}
{{ define "main" }}
{{ .Content }}
{{ end }}
{{ define "toc" }}
{{ .TableOfContents }}
{{ end }}
+1 -1
View File
@@ -1,5 +1,5 @@
<h2 class="book-brand">
<a href="{{ .Site.BaseURL }}">
<a href="{{ .Site.BaseURL | relLangURL }}">
{{- with .Site.Params.BookLogo -}}
<img src="{{ . | relURL }}" alt="Logo" />
{{- end -}}
+10 -19
View File
@@ -1,33 +1,24 @@
<div class="book-footer justify-between">
{{ if .Site.IsMultiLingual }}
<div class="flex justify-between">
{{ if .Site.IsMultiLingual }}
{{ partial "docs/languages" . }}
{{ end }}
{{ end }}
{{ if and .GitInfo .Site.Params.BookRepo }}
{{ with .GitInfo }}
{{ if and .GitInfo .Site.Params.BookRepo }}
<div>
{{ $date := .AuthorDate.Local.Format (default "January 2, 2006" $.Site.Params.BookDateFormat) }}
<a class="flex align-center" href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='{{ i18n "Last modified by" }} {{ .AuthorName }} | {{ $date }}' target="_blank">
{{ $date := .GitInfo.AuthorDate.Local.Format (default "January 2, 2006" .Site.Params.BookDateFormat) }}
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/commit/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
<span>{{ $date }}</span>
</a>
</div>
{{ end }}
{{ end }}
{{ end }}
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
<div>
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ replace .File.Path "\\" "/" }}" target="_blank">
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}/{{ replace .File.Path "\\" "/" }}" target="_blank" rel="noopener">
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="Edit" />
<span>{{ i18n "Edit this page" }}</span>
</a>
</div>
{{ end }}
</div>
{{ if (default true (default .Site.Params.BookComments .Params.bookComments)) }}
<div class="book-comments">
{{ partial "docs/comments" . }}
</div>
{{ end }}
</div>
+11
View File
@@ -0,0 +1,11 @@
<div class="flex align-center justify-between">
<label for="menu-control">
<img src="{{ "svg/menu.svg" | relURL }}" class="book-icon" alt="Menu" />
</label>
<strong>{{ partial "docs/title" . }}</strong>
<label for="toc-control">
<img src="{{ "svg/toc.svg" | relURL }}" class="book-icon" alt="Table of Contents" />
</label>
</div>
+3 -3
View File
@@ -1,12 +1,12 @@
<nav id="BookMenu">
<nav>
{{ partial "docs/brand" . }}
{{ partial "docs/search" . }}
{{ partial "docs/inject/menu-before" . }}
{{ if .Site.Params.BookMenuBundle }}
{{ partial "docs/menu-bundle" . }}
{{ partial "docs/menu-bundle" . }}
{{ else }}
{{ partial "docs/menu-filetree" . }}
{{ partial "docs/menu-filetree" . }}
{{ end }}
{{ partial "docs/inject/menu-after" . }}
-8
View File
@@ -1,8 +0,0 @@
<header class="flex align-center justify-between book-header">
<label id="menu-control" for="menu-control">
<img src="{{ "svg/menu.svg" | relURL }}" class="book-icon" alt="Menu" />
</label>
<label id="toc-control" for="toc-control">
<strong>{{ partial "docs/title" . }}</strong>
</label>
</header>
+3 -3
View File
@@ -1,4 +1,4 @@
{{ $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat }}
{{ $dateFormat := (default "January 2, 2006" .Site.Params.BookDateFormat) }}
{{ if or .Date .Params.tags }}
<div>
{{ with .Date}}
@@ -6,10 +6,10 @@
{{ end }}
{{ range $term, $_ := .Site.Taxonomies }}
{{ with $list := index $.Params $term }}
{{ with $list := $.Param $term }}
<div>
{{ range $n, $single := $list }}{{ if $n }}, {{ end }}
{{ with $.Site.GetPage (printf "/%s/%s" $term $single | urlize) }}
{{- with $.Site.GetPage (printf "/%s/%s" $term $single | urlize) }}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- end }}
{{- end }}
-2
View File
@@ -1,4 +1,3 @@
<aside class="book-toc fixed">
<nav>
<ul>
{{ range $term, $_ := .Site.Taxonomies }}
@@ -17,4 +16,3 @@
{{ end }}
</ul>
</nav>
</aside>
+1 -10
View File
@@ -1,10 +1 @@
{{ $tocLevels := default (default 6 .Site.Params.BookToC) .Params.BookToC }}
{{ if and $tocLevels .Page.TableOfContents }}
<aside class="book-toc levels-{{$tocLevels}} fixed">
{{ with .Page.TableOfContents }}
<label id="toc-control" for="toc-control">
{{ . }}
</label>
{{ end }}
</aside>
{{ end }}
{{ .TableOfContents }}
+1 -1
View File
@@ -1,7 +1,7 @@
<div class="book-expand">
<label>
<div class="book-expand-head flex justify-between">
<span>{{ default "Expand" (.Get 0) }}</span>
<span>{{ default (i18n "Expand") (.Get 0) }}</span>
<span>{{ default "↕" (.Get 1) }}</span>
</div>
<input type="checkbox" class="hidden" />