Added Toggle Indexes (#4544)

* Add monochrome theme with grayscale filter

* Add indexes toggle and disable starred

* Keep filters mutually exclusive
This commit is contained in:
Zenith Rifle 2026-01-05 10:43:34 +08:00 committed by GitHub
parent a34a97eb41
commit 361e48f862
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 87 additions and 13 deletions

View file

@ -17,23 +17,27 @@
import type { MarkdownRenderer } from 'vitepress'
const excluded = ['Beginners Guide']
const starredMarkers = [':star:', ':glowing-star:', '⭐', '🌟']
const indexMarkers = ['🌐', ':globe_with_meridians:', ':globe-with-meridians:']
export function toggleStarredPlugin(md: MarkdownRenderer) {
md.renderer.rules.list_item_open = (tokens, index, options, env, self) => {
const contentToken = tokens[index + 2]
// Ensure the token exists
if (contentToken) {
const content = contentToken.content
if (!contentToken) return self.renderToken(tokens, index, options)
if (
!excluded.includes(env.frontmatter.title) &&
(content.includes(':star:') || content.includes(':glowing-star:'))
) {
return `<li class="starred">`
}
}
const content = contentToken.content
const isStarred =
!excluded.includes(env.frontmatter.title) &&
starredMarkers.some((marker) => content.includes(marker))
const isIndex = indexMarkers.some((marker) => content.includes(marker))
return self.renderToken(tokens, index, options)
if (!isStarred && !isIndex) return self.renderToken(tokens, index, options)
const classes = []
if (isStarred) classes.push('starred')
if (isIndex) classes.push('index')
return `<li class="${classes.join(' ')}">`
}
}