From 06eba5781552ffc14f6c498015345ecf94547175 Mon Sep 17 00:00:00 2001 From: J S Date: Sun, 15 Oct 2023 00:17:04 -0400 Subject: [PATCH] feat[layouts/ static/]: Added search functionality Ripped off the onion theme from heracl.es --- layouts/_default/baseof.html | 22 + layouts/_default/index.json | 15 + layouts/_default/list.html | 38 +- layouts/_default/single.html | 19 +- layouts/partials/head.html | 3 + layouts/partials/page_header.html | 1 - layouts/partials/search.html | 21 + static/css/style.css | 5 +- static/scripts/askolonion/askolonion.js | 244 ++ static/scripts/askolonion/fuse.basic.min.js | 9 + static/scripts/askolonion/fuse.js | 2240 ++++++++++++++++++ static/scripts/fixedsearch/askolonion.js | 244 ++ static/scripts/fixedsearch/fuse.basic.min.js | 9 + 13 files changed, 2835 insertions(+), 35 deletions(-) create mode 100644 layouts/_default/baseof.html create mode 100644 layouts/_default/index.json create mode 100644 layouts/partials/search.html create mode 100644 static/scripts/askolonion/askolonion.js create mode 100644 static/scripts/askolonion/fuse.basic.min.js create mode 100644 static/scripts/askolonion/fuse.js create mode 100644 static/scripts/fixedsearch/askolonion.js create mode 100644 static/scripts/fixedsearch/fuse.basic.min.js diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..a3d7ac7 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,22 @@ + +{{ partial "head.html" . }} + + {{ partial "page_header.html" . }} + + +

{{ block "title" .}} + {{ .Title | title }} + {{- end }} +

+ + + {{ block "main" . }} + {{ .Content }} + + {{ end }} + + {{ block "footer" . }} + + {{ end }} + + diff --git a/layouts/_default/index.json b/layouts/_default/index.json new file mode 100644 index 0000000..1979cab --- /dev/null +++ b/layouts/_default/index.json @@ -0,0 +1,15 @@ +{{/* layouts/_default/index.json */}} +{{- $index := slice -}} +{{- range where .Site.RegularPages.ByDate.Reverse "Type" "not in" (slice "page" "json") -}} + {{ if .Params.dateCreated }} + {{ $.Scratch.Set "date" (.Params.dateCreated) }} + {{ else }} + {{- if isset site.Params "date_format" -}} + {{- $.Scratch.Set "date" (.Date.Format site.Params.date_format) -}} + {{- else -}} + {{- $.Scratch.Set "date" (.Date.Format "2006-01-02") -}} + {{- end -}} + {{ end }} + {{- $index = $index | append (dict "title" ( .Title | plainify ) "permalink" .Permalink "section" (i18n (.Section | title)) "tags" (apply .Params.tags "i18n" "." ) "categories" (apply .Params.categories "i18n" "." ) "summary" (.Params.summary | markdownify | htmlUnescape | plainify) "date" ($.Scratch.Get "date") ) -}} +{{- end -}} +{{- $index | jsonify -}} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index a3e5868..1aba3ec 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,23 +1,19 @@ - - -{{ partial "head.html" . }} +{{ define "main" -}} - - {{ partial "page_header.html" . }} +{{ .Content }} + +{{- end }} -

Posts

- -
- - - {{ range .Pages.ByPublishDate }} -
- {{ .Title }}
- -
-
- {{ end }} -
- - - \ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index e6f7376..12c64b2 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,13 +1,10 @@ - -{{ partial "head.html" . }} +{{ define "main" }} +

+

- -{{ partial "page_header.html" . }} -

{{ .Title }}

-

-

-{{ .Content }} + {{ .Content }} +{{ end }} -{{ partial "footer.html" . }} - - \ No newline at end of file +{{ define "footer" }} +{{partial "footer" .}} +{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index c85c218..165163e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,4 +1,5 @@ + {{ if not .IsHome }}{{ .Title | title }} | {{ end }}{{ .Site.Title }} @@ -12,4 +13,6 @@ integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous"> + {{ partialCached "search" . }} + diff --git a/layouts/partials/page_header.html b/layouts/partials/page_header.html index 19ff6f4..23bf447 100644 --- a/layouts/partials/page_header.html +++ b/layouts/partials/page_header.html @@ -3,7 +3,6 @@