mirror of https://github.com/jpanther/congo.git
♻️ Add search to JS asset bundle
parent
0842766212
commit
dcd5dd0ec9
|
@ -104,9 +104,7 @@ function fetchJSON(path, callback) {
|
|||
}
|
||||
|
||||
function buildIndex() {
|
||||
var baseURL = document
|
||||
.querySelector('script[data-id="fusejs"][data-url]')
|
||||
.getAttribute("data-url");
|
||||
var baseURL = wrapper.getAttribute("data-url");
|
||||
fetchJSON(baseURL + "index.json", function (data) {
|
||||
var options = {
|
||||
shouldSort: true,
|
||||
|
|
|
@ -56,6 +56,11 @@
|
|||
{{ $jsDark := resources.Get "js/dark.js" }}
|
||||
{{ $assets.Add "js" (slice $jsDark) }}
|
||||
{{ end }}
|
||||
{{ if .Site.Params.enableSearch | default false }}
|
||||
{{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }}
|
||||
{{ $jsSearch := resources.Get "js/search.js" }}
|
||||
{{ $assets.Add "js" (slice $jsFuse $jsSearch) }}
|
||||
{{ end }}
|
||||
{{ if $assets.Get "js" }}
|
||||
{{ $bundleJS := $assets.Get "js" | resources.Concat "js/main.bundle.js" | resources.Minify | resources.Fingerprint "sha512" }}
|
||||
<script defer type="text/javascript" src="{{ $bundleJS.RelPermalink }}" integrity="{{ $bundleJS.Data.Integrity }}"></script>
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
{{ $fuseLib := resources.Get "lib/fuse/fuse.min.js" }}
|
||||
{{ $fuseConfig := resources.Get "js/search.js" }}
|
||||
{{ $fuseConfig := $fuseConfig | resources.Minify }}
|
||||
{{ $fuseJS := slice $fuseLib $fuseConfig | resources.Concat "js/fuse.bundle.js" | resources.Fingerprint "sha512" -}}
|
||||
|
||||
<script defer type="text/javascript" src="{{ $fuseJS.RelPermalink }}" integrity="{{ $fuseJS.Data.Integrity }}" data-id="fusejs" data-url="{{ .Site.BaseURL }}"></script>
|
||||
<div
|
||||
id="search-wrapper"
|
||||
class="fixed inset-0 z-50 flex flex-col p-4 sm:p-6 md:p-[10vh] lg:p-[12vh] w-screen h-screen cursor-default bg-neutral-500/50 backdrop-blur-sm dark:bg-neutral-900/50 invisible"
|
||||
data-url="{{ .Site.BaseURL }}"
|
||||
>
|
||||
<div
|
||||
id="search-modal"
|
||||
|
|
Loading…
Reference in New Issue