From 80cca5b1befdbe1453bbf1bd92520403b0f5080f Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Wed, 12 Sep 2018 14:36:16 +0200 Subject: Simplify partials --- layouts/docs/baseof.html | 13 ++++++- layouts/partials/docs/nav-bundle.html | 11 ++---- layouts/partials/docs/nav-filetree.html | 56 +++++++++++++++++++++++++++++ layouts/partials/docs/nav-tree.html | 64 --------------------------------- layouts/partials/docs/nav.html | 5 --- 5 files changed, 71 insertions(+), 78 deletions(-) create mode 100644 layouts/partials/docs/nav-filetree.html delete mode 100644 layouts/partials/docs/nav-tree.html delete mode 100644 layouts/partials/docs/nav.html (limited to 'layouts') diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html index 8509b14..f7e8477 100644 --- a/layouts/docs/baseof.html +++ b/layouts/docs/baseof.html @@ -10,7 +10,18 @@
- {{ partial "docs/nav" . }} +
diff --git a/layouts/partials/docs/nav-bundle.html b/layouts/partials/docs/nav-bundle.html index 221325e..bdabefd 100644 --- a/layouts/partials/docs/nav-bundle.html +++ b/layouts/partials/docs/nav-bundle.html @@ -1,8 +1,3 @@ - +{{ with .Site.GetPage .Site.Params.BookMenuBundle }} + {{- .Content -}} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/docs/nav-filetree.html b/layouts/partials/docs/nav-filetree.html new file mode 100644 index 0000000..c5ecfc8 --- /dev/null +++ b/layouts/partials/docs/nav-filetree.html @@ -0,0 +1,56 @@ +{{ $bookSection := default "docs" .Site.Params.BookSection }} +{{ if eq $bookSection "*" }} + {{ .Scratch.Set "BookSections" .Site.Sections }} +{{ else }} + {{ $bookSections := where .Site.Sections "Section" $bookSection }} + {{ .Scratch.Set "BookSections" $bookSections }} + + {{ if eq (len $bookSections) 1 }} + {{ $singleSection := index $bookSections 0 }} + {{ .Scratch.Set "BookSections" $singleSection.Sections }} + {{ end }} +{{ end }} + +
    + {{ range .Scratch.Get "BookSections" }} + {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }} + {{ end }} +
+ + +{{ define "book-section" }} +
  • + {{ template "book-heading" .Section }} + +
  • +{{ end }} + + +{{ define "book-heading" }} + + {{ $sections := split (trim .Dir "/") "/" }} + {{ $title := index ($sections | last 1) 0 | humanize | title }} + {{ $title := default .Title $title }} + + {{ if .Content }} + + {{- $title -}} + + {{ else }} + + {{- $title -}} + + {{ end }} + +{{ end }} diff --git a/layouts/partials/docs/nav-tree.html b/layouts/partials/docs/nav-tree.html deleted file mode 100644 index 6d0a2d5..0000000 --- a/layouts/partials/docs/nav-tree.html +++ /dev/null @@ -1,64 +0,0 @@ -{{ $bookSection := default "docs" .Site.Params.BookSection }} -{{ if eq $bookSection "*" }} - {{ .Scratch.Set "BookSections" .Site.Sections }} -{{ else }} - {{ $bookSections := where .Site.Sections "Section" $bookSection }} - {{ .Scratch.Set "BookSections" $bookSections }} - - {{ if eq (len $bookSections) 1 }} - {{ $singleSection := index $bookSections 0 }} - {{ .Scratch.Set "BookSections" $singleSection.Sections }} - {{ end }} - -{{ end }} - - - - -{{ define "book-section" }} -
  • - {{ template "book-heading" .Section }} - -
  • -{{ end }} - - -{{ define "book-heading" }} - -{{ $sections := split (trim .Dir "/") "/" }} -{{ $title := index ($sections | last 1) 0 | humanize | title }} -{{ $title := default .Title $title }} - -{{ if .Content }} - - {{- $title -}} - -{{ else }} - - {{- $title -}} - -{{ end }} - -{{ end }} diff --git a/layouts/partials/docs/nav.html b/layouts/partials/docs/nav.html deleted file mode 100644 index 96bc233..0000000 --- a/layouts/partials/docs/nav.html +++ /dev/null @@ -1,5 +0,0 @@ -{{ if .Site.Params.BookMenuBundle }} - {{ partial "docs/nav-bundle" . }} -{{ else }} - {{ partial "docs/nav-tree" . }} -{{ end }} \ No newline at end of file -- cgit v1.2.3