mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
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:
@@ -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)
|
||||
Reference in New Issue
Block a user