diff --git a/docs/.vitepress/markdown/toggleStarred.ts b/docs/.vitepress/markdown/toggleStarred.ts index 3a56795fc..d2305f69f 100644 --- a/docs/.vitepress/markdown/toggleStarred.ts +++ b/docs/.vitepress/markdown/toggleStarred.ts @@ -19,7 +19,8 @@ const excluded = ['Beginners Guide'] export function toggleStarredPlugin(md: MarkdownRenderer) { md.renderer.rules.list_item_open = (tokens, index, options, env, self) => { - const contentToken = tokens[index + 2] + const contentToken = tokens[index + 2]; + if ( !excluded.includes(env.frontmatter.title) && contentToken && @@ -28,10 +29,15 @@ export function toggleStarredPlugin(md: MarkdownRenderer) { contentToken.content.includes(':star2:') ) ) { - // Replace the placeholders with HTML - contentToken.content = contentToken.content - .replace(':star:', '') // Use HTML for star - .replace(':star2:', '🌟'); // Use HTML for star2 + // Create a copy to avoid modifying the original token directly, which can cause issues. + let content = contentToken.content; + + // Replace :star2: FIRST to avoid conflicts + content = content.replace(/:star2:/g, '🌟'); + content = content.replace(/:star:/g, ''); + + // Update the token's content + contentToken.content = content; return `
  • `; }