添加服务端运行警告

This commit is contained in:
2026-04-09 15:46:54 +08:00
parent 2de3841f7d
commit cd689aba98
7 changed files with 43 additions and 24 deletions

21
src/lib/markdoc.server.ts Normal file
View File

@ -0,0 +1,21 @@
import './server-only.ts'
import { renderMarkdocTree } from './markdoc.ts'
import { generateCacheKey, markdocCache } from './markdoc-cache.server.ts'
export const getCachedMarkdocTree = async (content: string) => {
if (!import.meta.env.SSR) {
return await renderMarkdocTree(content)
}
const key = generateCacheKey(content)
const cached = await markdocCache.get(key)
if (cached) {
return cached
}
const tree = await renderMarkdocTree(content)
markdocCache.set(key, tree)
return tree
}