fumadocs-core
Version:
The React.js library for building a documentation website
26 lines (23 loc) • 662 B
JavaScript
'use client';
import { i as highlight } from "../shiki-4oMYwHED.js";
import { use, useMemo } from "react";
//#region src/highlight/client.tsx
const promises = {};
/**
* get highlighted results, should be used with React Suspense API.
*
* note: results are cached with (lang, code) as keys, if this is not the desired behaviour, pass a `deps` instead.
*/
function useShiki(code, options, deps) {
const key = useMemo(() => {
return deps ? JSON.stringify(deps) : `${options.lang}:${code}`;
}, [
code,
deps,
options.lang
]);
return use(promises[key] ??= highlight(code, options));
}
//#endregion
export { useShiki };
//# sourceMappingURL=client.js.map