mirror of
https://github.com/benjaminion/upgrading-ethereum-book.git
synced 2026-01-09 14:38:08 -05:00
Simplify search configuration
This commit is contained in:
@@ -112,8 +112,6 @@ module.exports = {
|
||||
pages: [],
|
||||
// Elements matching this query are ignored completely, including their text:
|
||||
ignore: 'svg, details, mtable, mrow, [aria-hidden="true"], .footnote-ref',
|
||||
// Chunks matching this query are excluded as duplicates (to handle nested matches):
|
||||
dedup: '[id^="fn-"] *, figcaption *, li *',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -21,12 +21,15 @@ const getChunks = ($, node, chunkTypes, exclude, counts) => {
|
||||
}
|
||||
|
||||
const chunks = []
|
||||
let matchedChunk = false;
|
||||
|
||||
for (let idx = 0; idx < chunkTypes.length; idx++) {
|
||||
|
||||
const type = chunkTypes[idx]
|
||||
if ($(node).is(type.query)) {
|
||||
|
||||
matchedChunk = true
|
||||
|
||||
const tagName = $(node).prop('tagName').toLowerCase()
|
||||
let id = $(node).attr('id')
|
||||
if ( id === undefined) {
|
||||
@@ -46,13 +49,17 @@ const getChunks = ($, node, chunkTypes, exclude, counts) => {
|
||||
weight: type.weight === undefined ? 1 : type.weight,
|
||||
})
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
$(node).children().not(exclude.ignore).not(exclude.dedup).each(function (i, e) {
|
||||
chunks.push(...getChunks($, e, chunkTypes, exclude, counts))
|
||||
})
|
||||
// We shouldn't recurse into chunks that we've already done
|
||||
if (!matchedChunk) {
|
||||
$(node).children().not(exclude.ignore).each(function (i, e) {
|
||||
chunks.push(...getChunks($, e, chunkTypes, exclude, counts))
|
||||
})
|
||||
}
|
||||
|
||||
return chunks
|
||||
}
|
||||
@@ -82,7 +89,7 @@ exports.createPages = async (
|
||||
const {
|
||||
enabled = true,
|
||||
chunkTypes = [],
|
||||
exclude = {frontmatter: [], pages: [], ignore: '', dedup: ''},
|
||||
exclude = {frontmatter: [], pages: [], ignore: ''},
|
||||
} = pluginOptions
|
||||
|
||||
const result = await graphql(`
|
||||
|
||||
Reference in New Issue
Block a user