Refactor templates and partials

This commit is contained in:
Alex Shpak 2018-11-25 13:30:25 +01:00
parent 461aafe995
commit 76c251066f
11 changed files with 57 additions and 33 deletions

View file

@ -26,6 +26,10 @@
margin: 0 auto; margin: 0 auto;
} }
.hide {
display: none;
}
@mixin fixed { @mixin fixed {
position: fixed; position: fixed;
top: 0; top: 0;
@ -34,6 +38,12 @@
overflow-y: auto; overflow-y: auto;
} }
.hide { @mixin dark-links {
display: none; a {
color: $nav-link-color;
}
a.active {
color: $color-link;
}
} }

View file

@ -103,13 +103,7 @@ ul.pagination {
@include fixed; @include fixed;
} }
a { @include dark-links;
color: $nav-link-color;
}
a.active {
color: $color-link;
}
} }
.book-page { .book-page {

View file

@ -1,5 +1,5 @@
--- ---
title: Index title: Introduction
type: docs type: docs
--- ---

View file

@ -2,7 +2,9 @@
{{ define "main"}} {{ define "main"}}
<main id="main"> <main id="main">
<div> <div>
<h1 id="title"><a href="{{ "/docs" }}">Go Home</a></h1> <h1 id="title"><a href="{{ "/" }}">Go Home</a></h1>
</div> </div>
</main> </main>
{{ end }} {{ end }}
{{ define "toc" }} {{ end }}

View file

@ -28,17 +28,10 @@
<div class="book-page"> <div class="book-page">
{{ partial "docs/mobile-header" . }} {{ partial "docs/mobile-header" . }}
<article class="markdown"> {{ template "main" . }}
{{- .Content -}}
</article>
</div> </div>
{{ $showToC := default (default true .Site.Params.BookShowToC) .Params.bookshowtoc }} {{ template "toc" . }}
{{ if and ($showToC) (.Page.TableOfContents) }}
<aside class="book-toc fixed">
{{ partial "docs/toc" . }}
</aside>
{{ end }}
{{ partial "docs/inject/body" . }} {{ partial "docs/inject/body" . }}
{{ template "_internal/google_analytics_async.html" . }} {{ template "_internal/google_analytics_async.html" . }}

View file

@ -1 +1,9 @@
{{ define "." }} {{ end }} {{ define "main" }}
<article class="markdown">
{{- .Content -}}
</article>
{{ end }}
{{ define "toc" }}
{{ partial "docs/toc" . }}
{{ end }}

View file

@ -1 +1,9 @@
{{ define "." }} {{ end }} {{ define "main" }}
<article class="markdown">
{{- .Content -}}
</article>
{{ end }}
{{ define "toc" }}
{{ partial "docs/toc" . }}
{{ end }}

View file

@ -1 +1,6 @@
{{ .Page.TableOfContents }} {{ $showToC := default (default true .Site.Params.BookShowToC) .Params.bookshowtoc }}
{{ if and ($showToC) (.Page.TableOfContents) }}
<aside class="book-toc fixed">
{{ .Page.TableOfContents }}
</aside>
{{ end }}

View file

@ -5,9 +5,11 @@
<h2> <h2>
<a href="{{ .Permalink }}">{{ .Title }}</a> <a href="{{ .Permalink }}">{{ .Title }}</a>
</h2> </h2>
<h5>{{ .Date.Format "January 2, 2006" }}</h5> <h5>
<strong>{{ .Date.Format "January 2, 2006" }}</strong>
</h5>
<p> <p>
{{ .Summary }} {{- .Summary -}}
{{ if .Truncated }} {{ if .Truncated }}
<a href="{{ .Permalink }}">...</a> <a href="{{ .Permalink }}">...</a>
{{ end }} {{ end }}

View file

@ -1,7 +1,9 @@
{{ define "main" }} {{ define "main" }}
<header> <header>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
<h5>{{ .Date.Format "January 2, 2006" }}</h5> <h5>
<strong>{{ .Date.Format "January 2, 2006" }}</strong>
</h5>
</header> </header>
<article class="markdown"> <article class="markdown">
{{- .Content -}} {{- .Content -}}