From dda0a0eab19457598b71f2b2b2f978b09d3f95c7 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Mon, 15 Jul 2019 18:25:21 +0200 Subject: Start work on search feature with lunr --- layouts/partials/docs/brand.html | 2 +- layouts/partials/docs/html-head.html | 9 ++++--- layouts/partials/docs/menu-bundle.html | 15 ++++++++++++ layouts/partials/docs/menu-filetree.html | 4 ++-- layouts/partials/docs/menu.html | 14 ++++++++--- layouts/partials/docs/mobile-header.html | 4 ++-- layouts/partials/docs/search.html | 2 ++ layouts/partials/docs/shared.html | 40 -------------------------------- layouts/partials/docs/title.html | 9 +++++++ 9 files changed, 48 insertions(+), 51 deletions(-) create mode 100644 layouts/partials/docs/search.html delete mode 100644 layouts/partials/docs/shared.html create mode 100644 layouts/partials/docs/title.html (limited to 'layouts/partials') diff --git a/layouts/partials/docs/brand.html b/layouts/partials/docs/brand.html index 5a2c9cb..7d7b721 100644 --- a/layouts/partials/docs/brand.html +++ b/layouts/partials/docs/brand.html @@ -1,3 +1,3 @@

{{ .Site.Title }} -

\ No newline at end of file + diff --git a/layouts/partials/docs/html-head.html b/layouts/partials/docs/html-head.html index 5fbc549..805c2b5 100644 --- a/layouts/partials/docs/html-head.html +++ b/layouts/partials/docs/html-head.html @@ -1,11 +1,14 @@ -{{- template "title" . }} | {{ .Site.Title -}} +{{ partial "docs/title" . }} | {{ .Site.Title -}} - -{{ $styles := resources.Get "book.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }} + +{{- $styles := resources.Get "book.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }} +{{- $search := resources.Get "search.js" | resources.ExecuteAsTemplate "search.js" . | resources.Minify | resources.Fingerprint }} + + diff --git a/layouts/partials/docs/menu-bundle.html b/layouts/partials/docs/menu-bundle.html index bfc1650..2aedb54 100644 --- a/layouts/partials/docs/menu-bundle.html +++ b/layouts/partials/docs/menu-bundle.html @@ -2,3 +2,18 @@ {{ with .Site.GetPage .Site.Params.BookMenuBundle }} {{- .Content -}} {{ end }} + +{{ define "hrefhack" }} + {{ $attrEq := "$=" }} + {{ $attrVal := .RelPermalink }} + {{ if eq .RelPermalink "/" }} + {{ $attrEq = "=" }} + {{ $attrVal = .Permalink }} + {{ end }} + + +{{ end }} diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html index 9ed63ea..abc6fd9 100644 --- a/layouts/partials/docs/menu-filetree.html +++ b/layouts/partials/docs/menu-filetree.html @@ -27,7 +27,7 @@ {{ if .Content }} {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} {{ else }} - {{ template "title" . }} + {{ partial "docs/title" . }} {{ end }} {{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }} @@ -53,7 +53,7 @@ {{ define "book-page-link" }} {{ with .Page }} - {{ template "title" . }} + {{ partial "docs/title" . }} {{ end }} {{ end }} diff --git a/layouts/partials/docs/menu.html b/layouts/partials/docs/menu.html index d280713..6a72ac9 100644 --- a/layouts/partials/docs/menu.html +++ b/layouts/partials/docs/menu.html @@ -1,5 +1,6 @@ -{{ if .Site.Params.BookEnableJS }} - {{ template "jsmenu" . }} -{{ end }} + + diff --git a/layouts/partials/docs/mobile-header.html b/layouts/partials/docs/mobile-header.html index b8fa2a9..720b83d 100644 --- a/layouts/partials/docs/mobile-header.html +++ b/layouts/partials/docs/mobile-header.html @@ -1,6 +1,6 @@ -
+
- {{- template "title" . }} + {{ partial "docs/title" . }}
diff --git a/layouts/partials/docs/search.html b/layouts/partials/docs/search.html new file mode 100644 index 0000000..d4b0e65 --- /dev/null +++ b/layouts/partials/docs/search.html @@ -0,0 +1,2 @@ + + diff --git a/layouts/partials/docs/shared.html b/layouts/partials/docs/shared.html deleted file mode 100644 index 2545dea..0000000 --- a/layouts/partials/docs/shared.html +++ /dev/null @@ -1,40 +0,0 @@ -{{/*These templates contains some more complex logic and shared between partials*/}} -{{ define "title" }} - {{ if and .IsSection .File }} - {{ $sections := split (trim .File.Dir "/") "/" }} - {{ $title := index ($sections | last 1) 0 | humanize | title }} - {{ default $title .Title }} - {{ else if and .IsPage .File }} - {{ $title := .File.BaseFileName | humanize | title }} - {{ default $title .Title }} - {{ else }} - {{ .Title }} - {{ end }} -{{ end }} - -{{ define "hrefhack" }} - {{ $attrEq := "$=" }} - {{ $attrVal := .RelPermalink }} - {{ if eq .RelPermalink "/" }} - {{ $attrEq = "=" }} - {{ $attrVal = .Permalink }} - {{ end }} - - -{{ end }} - -{{ define "jsmenu" }} - -{{ end }} diff --git a/layouts/partials/docs/title.html b/layouts/partials/docs/title.html new file mode 100644 index 0000000..91d5f81 --- /dev/null +++ b/layouts/partials/docs/title.html @@ -0,0 +1,9 @@ +{{ $title := .Title }} +{{ if and .IsSection .File }} + {{ $sections := split (trim .File.Dir "/") "/" }} + {{ $title = index ($sections | last 1) 0 | humanize | title }} +{{ else if and .IsPage .File }} + {{ $title = .File.BaseFileName | humanize | title }} +{{ end }} + +{{ return $title }} -- cgit v1.2.3