2023-11-12 16:42:57 +00:00
|
|
|
import type { MarkdownRenderer } from "vitepress";
|
|
|
|
|
|
|
|
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];
|
|
|
|
if (
|
|
|
|
!excluded.includes(env.frontmatter.title) &&
|
|
|
|
contentToken &&
|
2024-01-24 13:04:39 +00:00
|
|
|
contentToken.content.startsWith(":star:")
|
2023-11-12 16:42:57 +00:00
|
|
|
) {
|
|
|
|
return `<li class="starred">`;
|
2024-01-24 13:04:39 +00:00
|
|
|
} else {
|
|
|
|
return self.renderToken(tokens, index, options);
|
2023-11-12 16:42:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|