添加服务端运行警告
This commit is contained in:
@ -38,28 +38,10 @@ export const markdocConfig: Config = {
|
||||
},
|
||||
}
|
||||
|
||||
const _toMarkdocTree = async (content: string) => {
|
||||
export const renderMarkdocTree = async (content: string) => {
|
||||
const ast = Markdoc.parse(content)
|
||||
await ensureShikiEngine()
|
||||
const tree = Markdoc.transform(ast, markdocConfig)
|
||||
|
||||
return tree
|
||||
}
|
||||
|
||||
export const toMarkdocTree = async (content: string) => {
|
||||
if (!import.meta.env.SSR) {
|
||||
return await _toMarkdocTree(content)
|
||||
}
|
||||
|
||||
const cacheLib = await import('./markdoc-cache.ts')
|
||||
const key = cacheLib.generateCacheKey(content)
|
||||
const cached = await cacheLib.markdocCache.get(key)
|
||||
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const tree = await _toMarkdocTree(content)
|
||||
cacheLib.markdocCache.set(key, tree)
|
||||
return tree
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user