Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Users will now be able to create `div`s and `span`s that exclude
certain page elements from the search index.
  • Loading branch information
nickvigilante committed Oct 24, 2024
1 parent e928dd8 commit c09c580
Show file tree
Hide file tree
Showing 31 changed files with 5,027 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/project/types/website/website-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ export async function updateSearchIndex(
}
});

// Remove all page elements that should be excluded from the search index
const exclusions = doc.querySelectorAll(".quarto-exclude-from-search-index");
for (const exclusion of exclusions) {
exclusion._remove();
}

// We always take the first child of the main region (whether that is a p or section)
// and create an index entry for the page itself (with no hash). If there is other
// 'unsectioned' content on the page, we include that as well.
Expand Down
4 changes: 4 additions & 0 deletions tests/docs/search/issue-11189/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.quarto/
*.html
*.pdf
*_files/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: Remove-class
author: Nick Vigilante
version: 1.0.0
quarto-required: ">=99.9.0"
contributes:
filters:
- remove-class.lua

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

-- Reformat all heading text
function RemoveClass(el)
class = "quarto-exclude-from-search-index"
if el.classes:includes(class) then
el.classes:remove(class)
end
end
4 changes: 4 additions & 0 deletions tests/docs/search/issue-11189/_quarto-with-filter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project:
output-dir: _site_with_filter
post-render:
- check-index-with-filter.ts
4 changes: 4 additions & 0 deletions tests/docs/search/issue-11189/_quarto-without-filter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project:
output-dir: _site_without_filter
post-render:
- check-index-without-filter.ts
19 changes: 19 additions & 0 deletions tests/docs/search/issue-11189/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
project:
type: website

profile:
default: without-filter

website:
title: "issue-11189"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd

format:
html:
theme: cosmo
css: styles.css
toc: true
16 changes: 16 additions & 0 deletions tests/docs/search/issue-11189/_site_with_filter/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"objectID": "about.html",
"href": "about.html",
"title": "About",
"section": "",
"text": "About this site"
},
{
"objectID": "index.html",
"href": "index.html",
"title": "issue-11189",
"section": "",
"text": "This is a Quarto website.\nTo learn more about Quarto websites visit https://quarto.org/docs/websites."
}
]

Large diffs are not rendered by default.

Loading

0 comments on commit c09c580

Please sign in to comment.