From 76c251066fd34a26734bf1acdb1e041881e1c0af Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Sun, 25 Nov 2018 13:30:25 +0100 Subject: Refactor templates and partials --- assets/_utils.scss | 16 +++++++++++++--- assets/book.scss | 8 +------- exampleSite/content/_index.md | 2 +- layouts/404.html | 6 ++++-- layouts/docs/baseof.html | 13 +++---------- layouts/docs/list.html | 10 +++++++++- layouts/docs/single.html | 10 +++++++++- layouts/partials/docs/toc.html | 7 ++++++- layouts/posts/baseof.html | 2 +- layouts/posts/list.html | 10 ++++++---- layouts/posts/single.html | 6 ++++-- 11 files changed, 57 insertions(+), 33 deletions(-) diff --git a/assets/_utils.scss b/assets/_utils.scss index fd773d3..bb0120c 100644 --- a/assets/_utils.scss +++ b/assets/_utils.scss @@ -26,6 +26,10 @@ margin: 0 auto; } +.hide { + display: none; +} + @mixin fixed { position: fixed; top: 0; @@ -34,6 +38,12 @@ overflow-y: auto; } -.hide { - display: none; -} +@mixin dark-links { + a { + color: $nav-link-color; + } + + a.active { + color: $color-link; + } +} \ No newline at end of file diff --git a/assets/book.scss b/assets/book.scss index d476111..2032466 100644 --- a/assets/book.scss +++ b/assets/book.scss @@ -103,13 +103,7 @@ ul.pagination { @include fixed; } - a { - color: $nav-link-color; - } - - a.active { - color: $color-link; - } + @include dark-links; } .book-page { diff --git a/exampleSite/content/_index.md b/exampleSite/content/_index.md index 6cb0a37..772bbe8 100644 --- a/exampleSite/content/_index.md +++ b/exampleSite/content/_index.md @@ -1,5 +1,5 @@ --- -title: Index +title: Introduction type: docs --- diff --git a/layouts/404.html b/layouts/404.html index ca630ee..06ca617 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -2,7 +2,9 @@ {{ define "main"}}
-

Go Home

+

Go Home

-{{ end }} \ No newline at end of file +{{ end }} + +{{ define "toc" }} {{ end }} \ No newline at end of file diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html index 0f951cd..805e060 100644 --- a/layouts/docs/baseof.html +++ b/layouts/docs/baseof.html @@ -28,21 +28,14 @@
{{ partial "docs/mobile-header" . }} -
- {{- .Content -}} -
+ {{ template "main" . }}
- {{ $showToC := default (default true .Site.Params.BookShowToC) .Params.bookshowtoc }} - {{ if and ($showToC) (.Page.TableOfContents) }} - - {{ end }} + {{ template "toc" . }} {{ partial "docs/inject/body" . }} {{ template "_internal/google_analytics_async.html" . }} - \ No newline at end of file + diff --git a/layouts/docs/list.html b/layouts/docs/list.html index a54943b..ee001c9 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -1 +1,9 @@ -{{ define "." }} {{ end }} \ No newline at end of file +{{ define "main" }} +
+ {{- .Content -}} +
+{{ end }} + +{{ define "toc" }} + {{ partial "docs/toc" . }} +{{ end }} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index a54943b..ee001c9 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -1 +1,9 @@ -{{ define "." }} {{ end }} \ No newline at end of file +{{ define "main" }} +
+ {{- .Content -}} +
+{{ end }} + +{{ define "toc" }} + {{ partial "docs/toc" . }} +{{ end }} diff --git a/layouts/partials/docs/toc.html b/layouts/partials/docs/toc.html index aca3785..83c276d 100644 --- a/layouts/partials/docs/toc.html +++ b/layouts/partials/docs/toc.html @@ -1 +1,6 @@ -{{ .Page.TableOfContents }} \ No newline at end of file +{{ $showToC := default (default true .Site.Params.BookShowToC) .Params.bookshowtoc }} + {{ if and ($showToC) (.Page.TableOfContents) }} + +{{ end }} diff --git a/layouts/posts/baseof.html b/layouts/posts/baseof.html index 47371c0..fa97ee3 100644 --- a/layouts/posts/baseof.html +++ b/layouts/posts/baseof.html @@ -16,4 +16,4 @@ {{ template "_internal/google_analytics_async.html" . }} - \ No newline at end of file + diff --git a/layouts/posts/list.html b/layouts/posts/list.html index da13220..97873dd 100644 --- a/layouts/posts/list.html +++ b/layouts/posts/list.html @@ -5,14 +5,16 @@

{{ .Title }}

-
{{ .Date.Format "January 2, 2006" }}
+
+ {{ .Date.Format "January 2, 2006" }} +

- {{ .Summary }} + {{- .Summary -}} {{ if .Truncated }} - ... + ... {{ end }}

{{ end }} {{ template "_internal/pagination.html" . }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 9081faa..6b0712e 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -1,9 +1,11 @@ {{ define "main" }}

{{ .Title }}

-
{{ .Date.Format "January 2, 2006" }}
+
+ {{ .Date.Format "January 2, 2006" }} +
{{- .Content -}}
-{{ end }} \ No newline at end of file +{{ end }} -- cgit v1.2.3