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
Feature request: ignore certain HTML elements and/or item IDs #64
Comments
I've been waiting for someone to ask for this 😄 I would love to add it, so I'll have a wee scope. The streaming library we use for parsing files imposes some challenges here around being able to line up selectors with an element that we're indexing, but I have a rough plan for how to implement it 🙂 |
Hello, Search.md---
title: "Search"
<!-- date: 2022-11-14T21:43:06+01:00 -->
<!-- draft: true -->
Toc: false
readingTime: false
---
{{< raw_html >}}
<link href="/_pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/_pagefind/pagefind-ui.js" type="text/javascript"></script>
<div id="search"></div>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search" });
});
</script>
<style>
body {
--pagefind-ui-primary: #eeeeee;
--pagefind-ui-text: #eeeeee;
--pagefind-ui-background: #152028;
--pagefind-ui-border: #FFA86A;
--pagefind-ui-tag: #152028;
--pagefind-ui-font:'Fira Code'
}
</style>
{{</ raw_html >}} I'd love to disable the Btw, it works great. Like really great! Love it <3 |
Awesome, I'll write up some tests this week and see how hard they'll be to get passing. Keep you posted! |
Hi all, this is released in v0.10.0 🎉 Let me know how it works out! |
@bglw Wow, that was fast! One question. I cannot see if I can do something like this: I have a 404 page which looks like this in Hugo: {{ define "main" }}
<aside data-pagefind-ignore>
<div class="post">
<h1 class="post-title">404 — {{ $.Site.Params.missingContentMessage | default "Page not found..." }}</h1>
<div class="post-content">
<a href="{{ "/" | absURL }}">{{ $.Site.Params.missingBackButtonLabel | default "Back to home page" }} →</a>
</div>
</div>
</aside>
{{ end }} How would I disable the class "post" if it's child (post-title) has 404 in it? Is it possible? Edit: I'd delete the |
No way to disable something based on its content, no. A better solution here would be to use a custom glob to exclude the |
Just an additional note for those using Pagefind with the Eleventy SSG... if you use the official syntax highlighting plugin, you can make this setting in your config file (usually // prior to the main `module.exports` section...
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight')
// then, within the `module.exports` section...
eleventyConfig.addPlugin(syntaxHighlight, {
preAttributes: {
"data-pagefind-ignore": ""
}
}) ...h/t to |
In Hugo, the goldmark parser renders a footnote reference (i.e., the
<sup>
’d footnote number itself within text, as opposed to the actual resulting footnote below the text) as, e.g.,<sup id="fnref:1">...</sup>
. Since neither Hugo nor goldmark makes it possible to edit the HTML of footnote references* — and, thus, there’s no way to specifydata-pagefind-ignore
for them — it would be nice if one could make Pagefind ignore certain HTML elements and/or item IDs (in the latter case, perhaps any ID that begins withfnref
).[If one wished to exclude the actual footnotes, that also wouldn’t be available unless Pagefind also had the ability to exclude certain CSS classes (
<div class="footnotes" role="doc-endnotes">
), so I’m also mentioning that FYI.]* I searched the Hugo Discourse extensively concerning this item, and it appears it’s a long-standing request (at least 2016) deemed as undoable due to issues relating to both goldmark and Commonmark itself.
The text was updated successfully, but these errors were encountered: