docs: polish theme, playground, and reference pages

Improve readability of the docs site with updated light/dark tokens, shared
code-block styling, and playground editors that follow system color scheme.
Skip CookieHub on localhost, serve the browser bundle from theme source, and
use backtick titles on filter/tag reference pages for consistent navigation.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-06-07 12:33:48 +08:00
co-authored by Cursor
parent 499b221f33
commit f7250f4601
111 changed files with 394 additions and 202 deletions
+43
View File
@@ -0,0 +1,43 @@
'use strict'
/**
* Extend Prism's bash grammar with extra CLI commands for docs code blocks.
* Hexo loads scripts from docs/scripts/ during init, before `hexo generate`
* highlights fenced code via syntax_highlighter: prismjs.
*
* To highlight another command, add its name to EXTRA_BASH_COMMANDS below.
*/
const EXTRA_BASH_COMMANDS = [
'npx'
]
const Prism = require('prismjs')
require('prismjs/components/prism-bash')
function extendBashCommandHighlighting (commands) {
const bash = Prism.languages.bash
if (!bash || !bash.function) return
const fnToken = bash.function
const pattern = fnToken.pattern
if (!(pattern instanceof RegExp)) return
const source = pattern.source
const listMatch = source.match(/\(\?:([^)]+)\)(?=\(\?\=)/)
if (!listMatch) return
const existing = listMatch[1]
const toAdd = commands.filter((cmd) => {
const re = new RegExp(`(?:^|\\|)${cmd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\||$)`)
return !re.test(existing)
})
if (toAdd.length === 0) return
const extended = `${existing}|${toAdd.join('|')}`
fnToken.pattern = new RegExp(
source.replace(/\(\?:([^)]+)\)(?=\(\?\=)/, `(?:${extended})`),
pattern.flags
)
}
extendBashCommandHighlighting(EXTRA_BASH_COMMANDS)