From 93d47662b2ce5a6dc4867687386c912e8cd13720 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Thu, 29 Jun 2023 18:40:17 +0200 Subject: Added search option with lunr.js --- themes/simple/layouts/_default/index.json | 5 + themes/simple/layouts/_default/index.xml | 27 ++++++ themes/simple/layouts/_default/list.html | 13 +++ themes/simple/layouts/_default/notes.html | 5 +- themes/simple/layouts/_default/rss.xml | 27 ------ themes/simple/layouts/_default/single.html | 3 + themes/simple/layouts/partials/head.html | 2 +- themes/simple/layouts/partials/navigation.html | 8 ++ themes/simple/layouts/partials/search.html | 123 +++++++++++++++++++++++++ themes/simple/layouts/section/notes.xml | 27 ------ themes/simple/layouts/section/section.json | 5 + themes/simple/layouts/section/section.xml | 27 ++++++ 12 files changed, 216 insertions(+), 56 deletions(-) create mode 100644 themes/simple/layouts/_default/index.json create mode 100644 themes/simple/layouts/_default/index.xml delete mode 100644 themes/simple/layouts/_default/rss.xml create mode 100644 themes/simple/layouts/partials/search.html delete mode 100644 themes/simple/layouts/section/notes.xml create mode 100644 themes/simple/layouts/section/section.json create mode 100644 themes/simple/layouts/section/section.xml (limited to 'themes/simple/layouts') diff --git a/themes/simple/layouts/_default/index.json b/themes/simple/layouts/_default/index.json new file mode 100644 index 0000000..b8f3786 --- /dev/null +++ b/themes/simple/layouts/_default/index.json @@ -0,0 +1,5 @@ +{{- $.Scratch.Add "index" slice -}} +{{- range .Site.RegularPages -}} +{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "type" .Type "permalink" .RelPermalink "summary" .Summary) -}} +{{- end -}} +{{- $.Scratch.Get "index" | jsonify -}} diff --git a/themes/simple/layouts/_default/index.xml b/themes/simple/layouts/_default/index.xml new file mode 100644 index 0000000..1f29133 --- /dev/null +++ b/themes/simple/layouts/_default/index.xml @@ -0,0 +1,27 @@ + + + + + {{ .Site.Author.name }}'s Blog + {{ .Permalink }} + {{ .Site.Params.description }} + en-us + + {{ range (where .Site.RegularPages "Section" "posts") }} + + + {{ .Title }} + {{ .Permalink }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} + {{ .Permalink }} + + {{ " + {{ " + + + {{end}} + + + + diff --git a/themes/simple/layouts/_default/list.html b/themes/simple/layouts/_default/list.html index 589d07b..232598d 100644 --- a/themes/simple/layouts/_default/list.html +++ b/themes/simple/layouts/_default/list.html @@ -1,6 +1,19 @@ {{ define "main" }}
+ + {{ partial "search.html" . }} + + + + +

For interesting notes and + small experiments I usually partake + in, check the Notes page.

+
+

Blog posts

diff --git a/themes/simple/layouts/_default/notes.html b/themes/simple/layouts/_default/notes.html index 27ac958..02560b0 100644 --- a/themes/simple/layouts/_default/notes.html +++ b/themes/simple/layouts/_default/notes.html @@ -1,12 +1,15 @@ {{ define "main" }}
+ + {{ partial "search.html" . }} +

Notes, notes and notes

Notes about things I learn, things I do, things I want to remember, but never do. You can subscribe to this - RSS feed + RSS feed which contains only the notes without the blog posts.

diff --git a/themes/simple/layouts/_default/rss.xml b/themes/simple/layouts/_default/rss.xml deleted file mode 100644 index 1f29133..0000000 --- a/themes/simple/layouts/_default/rss.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {{ .Site.Author.name }}'s Blog - {{ .Permalink }} - {{ .Site.Params.description }} - en-us - - {{ range (where .Site.RegularPages "Section" "posts") }} - - - {{ .Title }} - {{ .Permalink }} - {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} - {{ with .Site.Author.email }}{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}{{end}} - {{ .Permalink }} - - {{ " - {{ " - - - {{end}} - - - - diff --git a/themes/simple/layouts/_default/single.html b/themes/simple/layouts/_default/single.html index 77354b7..cadfd7b 100644 --- a/themes/simple/layouts/_default/single.html +++ b/themes/simple/layouts/_default/single.html @@ -1,6 +1,9 @@ {{ define "main" }}
+ + {{ partial "search.html" . }} +
diff --git a/themes/simple/layouts/partials/head.html b/themes/simple/layouts/partials/head.html index 6d40525..fc481fc 100644 --- a/themes/simple/layouts/partials/head.html +++ b/themes/simple/layouts/partials/head.html @@ -5,7 +5,7 @@ - + diff --git a/themes/simple/layouts/partials/navigation.html b/themes/simple/layouts/partials/navigation.html index da42679..b65fe35 100644 --- a/themes/simple/layouts/partials/navigation.html +++ b/themes/simple/layouts/partials/navigation.html @@ -7,6 +7,14 @@