mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
replaceAll方法替换
This commit is contained in:
@@ -60,11 +60,12 @@ export async function getStaticProps ({ params: { keyword } }) {
|
||||
}
|
||||
post.results = []
|
||||
let hit = false
|
||||
const re = new RegExp(`${keyword}`, 'g')
|
||||
indexContent.forEach(c => {
|
||||
const index = c.toLowerCase().indexOf(keyword.toLowerCase())
|
||||
if (index > -1) {
|
||||
hit = true
|
||||
const referText = c?.replaceAll(keyword, `<span class='text-red-500'>${keyword}</span>`)
|
||||
const referText = c?.replace(re, `<span class='text-red-500'>${keyword}</span>`)
|
||||
post.results.push(`<span>${referText}</span>`)
|
||||
} else {
|
||||
post.results.push(`<span>${c}</span>`)
|
||||
|
||||
Reference in New Issue
Block a user