diff options
author | Oscar Najera <hi@oscarnajera.com> | 2023-11-09 17:49:27 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2023-11-09 17:49:27 +0100 |
commit | 4a826ff2748eafdbf63dd0547706ed7dc7ed3d76 (patch) | |
tree | 17b3f45d8b750d7fbd1de718e87fdcbfa44e7e5a /layouts/_default | |
parent | 76b72515b6d8078268077bd9d96db493fb7bd6f8 (diff) | |
download | hugo-minimalist-theme-4a826ff2748eafdbf63dd0547706ed7dc7ed3d76.tar.gz hugo-minimalist-theme-4a826ff2748eafdbf63dd0547706ed7dc7ed3d76.tar.bz2 hugo-minimalist-theme-4a826ff2748eafdbf63dd0547706ed7dc7ed3d76.zip |
Search page
Diffstat (limited to 'layouts/_default')
-rw-r--r-- | layouts/_default/search.html | 45 | ||||
-rw-r--r-- | layouts/_default/search.json | 13 |
2 files changed, 58 insertions, 0 deletions
diff --git a/layouts/_default/search.html b/layouts/_default/search.html new file mode 100644 index 0000000..bcbaad4 --- /dev/null +++ b/layouts/_default/search.html @@ -0,0 +1,45 @@ +{{ define "main" }} + <div class="mw7 center pa1"> + <header> + <h2 class="baskerville f2 lh-title mv3 ph1"> + {{ .Title }} + </h2> + </header> + + <form action="{{ .Permalink }}"> + <input + id="search-query" + name="q" + placeholder="search phrase" + class="near-black pa2 w-100" + /> + </form> + + <div id="search-results" class="mv2"></div> + </div> + + <template id="search-result-template"> + <article class="pv2 bt bb b--black-10 search_summary"> + <a class="link dim near-black search_link" href=""> + <time class="fr f6 lh-copy ph4 search_time"></time> + <h3 class="f3 baskerville mv1 lh-title search_title"></h3> + <div class="f5 lh-copy search_snippet"></div> + </a> + </article> + </template> + <script + src="https://cdnjs.cloudflare.com/ajax/libs/fuse.js/7.0.0/fuse.min.js" + integrity="sha512-GrJ4P9yra6dftp5O0eaKFKS4ch1FYn1xR/VCHQIMJO1LNqcKhjkAkAETHYoE81Ffh3BjCJMWA/AZSYP521jxFA==" + crossorigin="anonymous" + referrerpolicy="no-referrer" + ></script> + + {{ with resources.Get "js/search.js" | resources.Minify | fingerprint }} + <script + src="{{ .RelPermalink }}" + integrity="{{ .Data.Integrity }}" + crossorigin="anonymous" + referrerpolicy="no-referrer" + ></script> + {{ end }} +{{ end }} diff --git a/layouts/_default/search.json b/layouts/_default/search.json new file mode 100644 index 0000000..16912cb --- /dev/null +++ b/layouts/_default/search.json @@ -0,0 +1,13 @@ + +{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2, 2006" }} +{{- $.Scratch.Add "index" slice -}} +{{- range (where .Site.RegularPages "Type" "in" .Site.Params.mainSections) -}} + + {{- $.Scratch.Add "index" (dict "title" .Title + "tags" .Params.tags + "categories" .Params.categories + "contents" (.Summary | plainify) + "date" (.Date.Format $dateFormat) + "permalink" .Permalink) -}} +{{- end -}} +{{- $.Scratch.Get "index" | jsonify -}} |