Skip to content

Commit c09c580

Browse files
committed
Fixes #11189
- Users will now be able to create `div`s and `span`s that exclude certain page elements from the search index.
1 parent e928dd8 commit c09c580

31 files changed

+5027
-0
lines changed

src/project/types/website/website-search.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ export async function updateSearchIndex(
291291
}
292292
});
293293

294+
// Remove all page elements that should be excluded from the search index
295+
const exclusions = doc.querySelectorAll(".quarto-exclude-from-search-index");
296+
for (const exclusion of exclusions) {
297+
exclusion._remove();
298+
}
299+
294300
// We always take the first child of the main region (whether that is a p or section)
295301
// and create an index entry for the page itself (with no hash). If there is other
296302
// 'unsectioned' content on the page, we include that as well.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.quarto/
2+
*.html
3+
*.pdf
4+
*_files/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Remove-class
2+
author: Nick Vigilante
3+
version: 1.0.0
4+
quarto-required: ">=99.9.0"
5+
contributes:
6+
filters:
7+
- remove-class.lua
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
-- Reformat all heading text
3+
function RemoveClass(el)
4+
class = "quarto-exclude-from-search-index"
5+
if el.classes:includes(class) then
6+
el.classes:remove(class)
7+
end
8+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project:
2+
output-dir: _site_with_filter
3+
post-render:
4+
- check-index-with-filter.ts
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project:
2+
output-dir: _site_without_filter
3+
post-render:
4+
- check-index-without-filter.ts
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project:
2+
type: website
3+
4+
profile:
5+
default: without-filter
6+
7+
website:
8+
title: "issue-11189"
9+
navbar:
10+
left:
11+
- href: index.qmd
12+
text: Home
13+
- about.qmd
14+
15+
format:
16+
html:
17+
theme: cosmo
18+
css: styles.css
19+
toc: true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"objectID": "about.html",
4+
"href": "about.html",
5+
"title": "About",
6+
"section": "",
7+
"text": "About this site"
8+
},
9+
{
10+
"objectID": "index.html",
11+
"href": "index.html",
12+
"title": "issue-11189",
13+
"section": "",
14+
"text": "This is a Quarto website.\nTo learn more about Quarto websites visit https://quarto.org/docs/websites."
15+
}
16+
]

tests/docs/search/issue-11189/_site_with_filter/site_libs/bootstrap/bootstrap-8603c7c062662f1caead21ebe114d4bc.min.css

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)