diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 4f7cd942..d1dff9c2 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -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, `${keyword}`) + const referText = c?.replace(re, `${keyword}`) post.results.push(`${referText}`) } else { post.results.push(`${c}`)