Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse search - local fast search that's instant and accurate. (see: PaperMod theme) #370

Open
ventz opened this issue Dec 21, 2023 · 1 comment
Labels

Comments

@ventz
Copy link

ventz commented Dec 21, 2023

Hi,

Would you consider adding Fuse search?
(https://www.fusejs.io/getting-started/installation.html)

See PaperMod theme for a very simple implementation: https://github.com/adityatelange/hugo-PaperMod

There are 2 files:

  • PaperMod/assets/js/fuse.basic.min.js /jane/assets/js/.
  • PaperMod/assets/js/fastsearch.js /jane/assets/js/.

Relevant section on how to use it: `PaperMod/layouts/partials/head.html

{{- /* Search */}}
{{- if (eq .Layout `search`) -}}
<link crossorigin="anonymous" rel="preload" as="fetch" href="../index.json">
{{- $fastsearch := resources.Get "js/fastsearch.js" | js.Build (dict "params" (dict "fuseOpts" site.Params.fuseOpts)) | resources.Minify }}
{{- $fusejs := resources.Get "js/fuse.basic.min.js" }}
{{- $license_js := resources.Get "js/license.js" }}
{{- if not site.Params.assets.disableFingerprinting }}
{{- $search := (slice $fusejs $license_js $fastsearch ) | resources.Concat "assets/js/search.js" | fingerprint }}
<script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}" integrity="{{ $search.Data.Integrity }}"></script>
{{- else }}
{{- $search := (slice $fusejs $fastsearch ) | resources.Concat "assets/js/search.js" }}
<script defer crossorigin="anonymous" src="{{ $search.RelPermalink }}"></script>
{{- end }}
{{- end -}}
@ventz
Copy link
Author

ventz commented Dec 21, 2023

Assuming this may be an even faster approach:
https://github.com/kaushalmodi/hugo-search-fuse-js

There is a good "how to" here too:
https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants