mirror of
https://github.com/benjaminion/upgrading-ethereum-book.git
synced 2026-01-10 06:57:58 -05:00
Simplify search index exclusions
This commit is contained in:
@@ -84,10 +84,7 @@ function getChunks(tree, chunkTypes, exclude) {
|
||||
}
|
||||
|
||||
function includePage(frontmatter, exclude) {
|
||||
return (
|
||||
exclude.pages?.indexOf(frontmatter.path) === -1 &&
|
||||
!isExcludedFrontmatter(frontmatter, exclude)
|
||||
);
|
||||
return !isExcludedFrontmatter(frontmatter, exclude);
|
||||
}
|
||||
|
||||
function buildSearchIndex(options) {
|
||||
|
||||
@@ -8,26 +8,28 @@ if (minimal) {
|
||||
|
||||
const pages = defineCollection({
|
||||
loader: minimal
|
||||
? glob({ pattern: "**/preface.md", base: "./src/md/pages" })
|
||||
: glob({ pattern: "**/*.md", base: "./src/md/pages" }),
|
||||
? glob({ pattern: '**/preface.md', base: './src/md/pages' })
|
||||
: glob({ pattern: '**/*.md', base: './src/md/pages' }),
|
||||
schema: z.object({
|
||||
hide: z.boolean(),
|
||||
path: z.string(),
|
||||
titles: z.array(z.string()),
|
||||
index: z.array(z.number()),
|
||||
sequence: z.number(),
|
||||
search: z.boolean().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
const special = defineCollection({
|
||||
loader: minimal
|
||||
? glob({ pattern: "search.md", base: "./src/md" })
|
||||
: glob({ pattern: "*.md", base: "./src/md" }),
|
||||
? glob({ pattern: 'search.md', base: './src/md' })
|
||||
: glob({ pattern: '*.md', base: './src/md' }),
|
||||
schema: z.object({
|
||||
path: z.string(),
|
||||
titles: z.array(z.string()).optional(),
|
||||
index: z.array(z.number()).optional(),
|
||||
sequence: z.number().optional(),
|
||||
search: z.boolean().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -58,9 +58,11 @@ const SearchOptions = {
|
||||
],
|
||||
exclude: {
|
||||
// Note, only pages under src/md/pages have a "hide" property.
|
||||
frontmatter: [{ key: 'hide', value: true }],
|
||||
// No point indexing these.
|
||||
pages: ['/', '/404/', '/contents/', '/search/', '/annotated-spec/'],
|
||||
frontmatter: [
|
||||
{ key: 'hide', value: true },
|
||||
{ key: 'search', value: false },
|
||||
{ key: 'path', value: '/annotated-spec/' },
|
||||
],
|
||||
// Elements matching this query are ignored completely, including their text:
|
||||
ignore:
|
||||
'svg, details, mtable, mrow, [aria-hidden="true"], a[id^="fnref-"], a.data-footnote-backref',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
path: /404/
|
||||
search: false
|
||||
---
|
||||
|
||||
# Not Found
|
||||
|
||||
@@ -3,6 +3,7 @@ path: /contents/
|
||||
titles: ["Contents"]
|
||||
index: [-1]
|
||||
sequence: -1
|
||||
search: false
|
||||
---
|
||||
|
||||
# Contents
|
||||
|
||||
@@ -3,6 +3,7 @@ path: /search/
|
||||
titles: ["Search"]
|
||||
index: [-1]
|
||||
sequence: -2
|
||||
search: false
|
||||
---
|
||||
|
||||
# Search
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
path: /
|
||||
search: false
|
||||
---
|
||||
|
||||
<div class="title-page">
|
||||
|
||||
Reference in New Issue
Block a user