feat(plugin-search): optimize search index logger (#676)

This commit is contained in:
pengzhanbo 2025-08-20 02:31:25 +08:00 committed by GitHub
parent 94e755c422
commit 22a5f10add
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -147,14 +147,25 @@ ${page.contentRendered}`
break
const { anchor, text, titles } = section
const id = anchor ? [fileId, anchor].join('#') : fileId
const item = {
id,
text,
title: titles.at(-1)!,
titles: titles.slice(0, -1),
if (index.has(id)) {
if (anchor) {
logger.error(`${colors.green('[@vuepress-plume/plugin-search]')} duplicate heading anchor : ${colors.cyan(titles.join(' >> '))} \n at ${colors.cyan(fileId)}`)
}
else {
logger.error(`${colors.green('[@vuepress-plume/plugin-search]')} duplicate page permalink : ${colors.cyan(fileId)}`)
}
}
else {
const item = {
id,
text,
title: titles.at(-1)!,
titles: titles.slice(0, -1),
}
index.add(item)
cache.push(item)
}
index.add(item)
cache.push(item)
}
}