Skip to content

Conversation

@ldez
Copy link
Contributor

@ldez ldez commented Aug 11, 2025

This PR allows the search to find the right section by parsing all the headings.

For example, if you are looking for "logo" inside the example site, the search will give you #nagivation.
This is right, but not what exactly you are looking for (#logo-and-title).

FYI, utils/extract-headings.html is a recursive partial.

The size of search-data.json is nearly the same because it contains the same content, but it is split differently, with only some keys added.

Related to #169

I also fixed a regression from c11c3c3

@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit 229da50
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/6899ce580f0daa00091490a0
😎 Deploy Preview https://deploy-preview-740--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ldez ldez force-pushed the feat/search-all-headings branch from a457b68 to 229da50 Compare August 11, 2025 11:04
Copy link
Owner

@imfing imfing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! It looks good overall.
My only suggestion is to use PAGE.Store instead of scratch.

https://gohugo.io/methods/page/store/

@@ -0,0 +1,31 @@
{{- /*
Extracts all headings from a page and adds them to the scratchpad.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scratch has been deprecated: https://gohugo.io/methods/page/scratch/

Deprecated in v0.138.0

Use the PAGE.Store method instead.

Copy link
Contributor Author

@ldez ldez Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PAGE.Scratch is deprecated, not newScratch (maps.Scratch):

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, thanks

@imfing imfing merged commit 532cbcc into imfing:main Aug 12, 2025
4 checks passed
@ldez ldez deleted the feat/search-all-headings branch August 12, 2025 01:30
@imfing
Copy link
Owner

imfing commented Aug 12, 2025

looks good on https://imfing.github.io/hextra/versions/latest/

image

@ldez ldez changed the title feat: search in all headings feat(flexsearch): search in all headings Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants