mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-28 10:50:40 +01:00
docs(app): implement AI search
This commit is contained in:
21
docs/app/composables/useHighlighter.ts
Normal file
21
docs/app/composables/useHighlighter.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createHighlighter, type HighlighterGeneric } from 'shiki'
|
||||
import { createJavaScriptRegexEngine } from 'shiki/engine-javascript.mjs'
|
||||
|
||||
let highlighter: HighlighterGeneric<any, any> | null = null
|
||||
|
||||
let promise: Promise<HighlighterGeneric<any, any>> | null = null
|
||||
|
||||
export const useHighlighter = async () => {
|
||||
if (!promise) {
|
||||
promise = createHighlighter({
|
||||
langs: ['vue', 'js', 'ts', 'css', 'html', 'json', 'yaml', 'markdown', 'bash'],
|
||||
themes: ['material-theme-palenight', 'material-theme-lighter'],
|
||||
engine: createJavaScriptRegexEngine()
|
||||
})
|
||||
}
|
||||
if (!highlighter) {
|
||||
highlighter = await promise
|
||||
}
|
||||
|
||||
return highlighter
|
||||
}
|
||||
Reference in New Issue
Block a user