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

Plainify flexsearch index values #511

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

schnerring
Copy link
Contributor

@schnerring schnerring commented Oct 14, 2021

Currently, the flexsearch index is populated with the non-planified .Content page variable.

You can try searching for the following and be able to find results: <div class="alert alert-warning d-flex" which is not part of the actual content but rather rendered HTML.

Using .Plain fixes this:

.Plain
the Page content stripped of HTML tags and presented as a string.
https://gohugo.io/variables/page/

I inserted the following in content/en/docs/prolouge/commands.md to test whether you can search for HTML tags that are part of the actual content:

### styles

Check styles for errors:

```html
npm run lint:styles [-- --fix]
<div class="test">foobar</div>
```

And it works:

  • <div class="test">foo returns a search result
  • <div class="alert alert-warning d-flex" doesn't return search results

On top of that the resulting index.js is way smaller:

  • development: 32.2 kB -> 15.3 kB (~27% smaller)
  • production: 15.3 kB -> 7 kB (~54% smaller)

Copy link
Member

@h-enk h-enk left a comment

Choose a reason for hiding this comment

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

Wow! Thanks, thanks, thanks. Verified (https://deploy-preview-511--doks.netlify.app/).

@h-enk h-enk merged commit cd1f9f5 into gethyas:master Oct 15, 2021
@h-enk
Copy link
Member

h-enk commented Oct 15, 2021

Since your deep in FlexSearch now 😉 , do you have any ideas for #514?

adhadse pushed a commit to adhadse/doks that referenced this pull request Sep 17, 2022
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.

None yet

2 participants