From 8678e82154226d31ff2833c83fc078d6260a218f Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Tue, 18 Sep 2018 01:35:54 +0200 Subject: Improve side menu rendering --- README.md | 6 +++- assets/_markdown.scss | 4 +++ assets/styles.scss | 3 +- layouts/docs/baseof.html | 2 +- layouts/partials/docs/nav-filetree.html | 58 +++++++++++++++------------------ layouts/partials/docs/shared.html | 4 +-- 6 files changed, 41 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 5bb44fe..5828986 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ Given you have this file structure Create file `content/docs/menu/index.md` with content ```md +--- +headless: true +--- + - [Book Example](/docs/) - [Page One](/docs/page-one) - [Page Two](/docs/page-two) @@ -87,7 +91,7 @@ type: docs weight: 10 # (Optional) Set to mark page as top level section in file-tree menu (if BookMenuBundle not set) -bookTopSection: true +bookRootSection: true # (Optional) Set to hide table of contents, overrides global value bookShowToC: false diff --git a/assets/_markdown.scss b/assets/_markdown.scss index b898b75..709210a 100644 --- a/assets/_markdown.scss +++ b/assets/_markdown.scss @@ -6,6 +6,10 @@ $block-border-radius: 0.15rem; h1, h2, h3, h4, h5 { font-weight: 400; } + + b, optgroup, strong { + font-weight: 400; + } a { text-decoration: none; diff --git a/assets/styles.scss b/assets/styles.scss index 670eb76..c36d583 100644 --- a/assets/styles.scss +++ b/assets/styles.scss @@ -25,6 +25,7 @@ a { .book-brand { padding: 0 $padding-16; + margin-bottom: $padding-8; font-weight: 400; a { @@ -73,7 +74,7 @@ a { } } - // class used for sections with bookTopSection: true + // class used for sections with bookRootSection: true .book-nav-section { margin-bottom: $padding-16; > a { font-weight: 600; } diff --git a/layouts/docs/baseof.html b/layouts/docs/baseof.html index 4119888..3a97228 100644 --- a/layouts/docs/baseof.html +++ b/layouts/docs/baseof.html @@ -1,5 +1,5 @@ - +{{- partial "docs/shared" -}} {{ partial "docs/html-head" . }} diff --git a/layouts/partials/docs/nav-filetree.html b/layouts/partials/docs/nav-filetree.html index 7c80ae2..6c2f965 100644 --- a/layouts/partials/docs/nav-filetree.html +++ b/layouts/partials/docs/nav-filetree.html @@ -1,51 +1,47 @@ -{{ template "book-get-root-section" . }} +{{ template "book-get-root-section" . }} - - - -{{ define "book-section" }} -
  • +{{- range .Scratch.Get "BookSections" -}} + {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }} +{{- end -}} - {{ with .Section}} +{{ define "book-section" }} + +{{ end }} - -
  • +{{ define "book-page-link" }} +{{- with .Page -}} + + {{- template "title" . -}} + +{{- end -}} {{ end }} {{ define "book-get-root-section" }} - + {{ $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 }} {{ end }} \ No newline at end of file diff --git a/layouts/partials/docs/shared.html b/layouts/partials/docs/shared.html index f7ba182..91c71b6 100644 --- a/layouts/partials/docs/shared.html +++ b/layouts/partials/docs/shared.html @@ -3,9 +3,9 @@ {{- if .Pages -}} {{ $sections := split (trim .Dir "/") "/" }} {{ $title := index ($sections | last 1) 0 | humanize | title }} - {{- default .Title $title -}} + {{- default $title .Title -}} {{- else -}} {{ $title := .File | humanize | title }} - {{- default .Title $title -}} + {{- default $title .Title -}} {{- end -}} {{ end }} -- cgit v1.2.3