fix: exclude-selectors matches are excluded entirely, not just ignored
--exclude-selectors marked a match as "ignored", the same as a bare data-pagefind-ignore, so metadata and filters inside the match were still collected. Excluding img.emoji, for example, still let the emoji become the page's auto-detected image. The status was also applied after the element had been processed. For a void element such as <img> that is too late twice over: its metadata has already been read, and the parser has already popped back to the parent, so the status landed on the parent instead and wiped out the rest of the page. Match the selectors in a handler registered ahead of the main element handler, which now reads that flag and gives the node Excluded status up front. The built-in REMOVE_SELECTORS (head, nav, footer, ...) keep the old Ignored status, so metadata tagged inside them still counts. Fixes #692
This commit is contained in:
1 parent
5205bba40d
commit
a36c86c90c
2 files changed
+80
-19
No files matched your search
@@ -63,7 +63,7 @@ exclude_selectors:
|
||||
- "[id^='prefix-']"
|
||||
```
|
||||
|
||||
All children will also be ignored, so using a `#my_navigation *` selector is not required — in other words, the semantics are the same as the [data-pagefind-ignore](/docs/indexing/#removing-individual-elements-from-the-index) attribute.
|
||||
All children will also be excluded, so using a `#my_navigation *` selector is not required. In other words, the semantics are the same as the [data-pagefind-ignore="all"](/docs/indexing/#removing-individual-elements-from-the-index) attribute: matched elements are skipped for metadata and filters as well as for content.
|
||||
|
||||
Note that currently Pagefind only supports lists of options via configuration files. If using the `--exclude-selectors` CLI flag or the `PAGEFIND_EXCLUDE_SELECTORS` environment variable, only one selector may be supplied. The selector may be a comma-separated CSS selector though, so the above example can be passed as `--exclude-selectors "#my_navigation, blockquote > span, [id^='prefix-']"`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user