kaushalmodi / hugo-search-fuse-js

Hugo theme component for implementing static site search using Fuse.js
https://hugo-search-fuse-js.netlify.app/
GNU General Public License v3.0
68 stars 23 forks source link

Exclude org-mode Toc from results & Add netlify-plugin-minify-html plugin support & Move code to partials #10

Closed Robin-Wils closed 1 year ago

Robin-Wils commented 3 years ago

Exclude org-mode Toc from results

This change should only affect org-mode Toc's. They will be excluded from the search results.

Add netlify-plugin-minify-html plugin support

Comments for the minifier will be added if users add "useHtmlMin = true" in their hugo config. These comments have to be on the same line as the element they surround. It will break the search otherwise. The "removeEmptyElements = true" option of the netlify-plugin-minify-html plugin broke this theme. This fixes that.

Move code to partials

This removes the requirement of needed a main and a footer in your theme. It also makes it possible for users to customise the search page. They can override partials in the theme which they use by adding them under "layouts/partials". This can also be done with the search page if the user adds "layouts/_default/search.html" in their theme.

I do have some overrides ready locally for my website, if you need an example.

NOTE

This change shouldn't break any existing projects, but trying it out before merging it to master seems like a smart thing to do. It works on my machine, but does it work on yours?

Robin-Wils commented 3 years ago

Demo: https://www.robinwils.com/search/?q=keepass

Modified values in my theme: The search.html, search-header.html and search-form.html pages are overriden to custom themed versions. The optional useHtmlMin toggle is turned on in the config:

Features in this demo: It includes the regex feature (the other pull-request) and the feature of this pull-request.

I will switch back to this repository on my theme when the pull-requests are ready. I currently use my fork, so that there is a demo.

kaushalmodi commented 3 years ago

This removes the requirement of needed a main and a footer in your theme.

I see that the partials are still called inside {{ define "main" }} and {{ define "footer" }}. So that requirement is still there, right?

Robin-Wils commented 3 years ago

It depends on how you use it. You don't have to use the default search page. I overrided it. Also just including the search-body and search-js partials on a page should result in a working search.

Partials: https://github.com/Robin-Wils/hugo-search-fuse-js/tree/master/layouts/partials

Robin-Wils commented 3 years ago

The requirement might still be there, if people don't override it. I haven't tested that. I think it is still a requirement on the default search page if people don't want to override it in their theme.

That page can be removed, but that will require people to call the partials. That page keeps the search theme compatible with previous versions of the theme. The update shouldn't break anything because that page exists.

kaushalmodi commented 2 years ago

Sorry for the late reply. If you can spend more time on this, can you please split the whole PR into multiple PRs, each for a different fix or feature?

Thanks!

Robin-Wils commented 2 years ago

Sure, will do.

Robin-Wils commented 1 year ago

I think I previously made those separate pull-requests. But I am not sure anymore. Will close this to avoid confusion.