Add Stork support

This commit is contained in:
Elnu 2022-07-17 17:03:23 -07:00
parent ce25ef91c6
commit 65853fccd2
7 changed files with 130 additions and 8 deletions

View file

@ -2,6 +2,10 @@
<html>
{{- partial "head.html" . -}}
<body>
{{ if .Site.Params.Stork }}
{{ partial "stork.html" . }}
<br>
{{ end }}
{{- partial "header.html" . -}}
<div id="content">
{{- block "main" . }}{{- end }}

View file

@ -0,0 +1,46 @@
{{- /*
https://stork-search.net/
https://stork-search.net/docs/
https://stork-search.net/docs/config-ref
https://stork-search.net/themes
https://github.com/jameslittle230/stork
https://github.com/jameslittle230/stork/discussions
*/}}
{{- /* Configuration */}}
{{- $config := dict
"input" (dict
"base_directory" "public"
"exclude_html_selector" ".highlight"
"html_selector" "#main"
"title_boost" "Moderate"
)
"output" (dict
"displayed_results_count" 5
"excerpts_per_result" 3
"save_nearest_html_id" true
)
}}
{{- /* Build the files map */}}
{{- $files := slice }}
{{- range site.Sections }}
{{- if eq .Section "tests" }}
{{- continue }}
{{- end }}
{{- range .Pages }}
{{- $file := dict
"title" (trim (partial "content.html" .Title) "\n")
"url" .RelPermalink
"path" (path.Join (strings.TrimPrefix site.BaseURL .Permalink) "index.html")
"filetype" "HTML"
}}
{{- $files = $files | append $file }}
{{- end }}
{{- end }}
{{- /* Merge the files map into the configuration map */}}
{{- $config = merge $config (dict "input" (dict "files" $files)) }}
{{- /* Render */}}
{{- jsonify (dict "indent" " ") $config }}

View file

@ -15,12 +15,14 @@
</details>
</aside>
{{ end }}
<article>
<header>
<h1>{{ partial "content.html" .Title }}</h1>
{{ partial "metadata.html" . }}
</header>
<br>
{{ partial "content.html" .Content }}
</article>
<main>
<article>
<header>
<h1>{{ partial "content.html" .Title }}</h1>
{{ partial "metadata.html" . }}
</header>
<br>
<div id="main">{{ partial "content.html" .Content }}</div>
</article>
</main>
{{ end }}

View file

@ -0,0 +1,13 @@
<div class="stork-search">
<input data-stork="posts" placeholder="🔎 Search {{ .Site.Title }}...">
</div>
<div data-stork="posts-output"></div>
<link rel="stylesheet" href="/stork/stork.css">
<script src="/stork/stork.js"></script>
<script>
stork.initialize("/stork/stork.wasm");
stork.register(
"posts",
"/home.st"
);
</script>