mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: Fix typings of HighlightOptions
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
Fix typings of `HighlightOptions`
|
||||
@@ -3,8 +3,9 @@ import {
|
||||
type CodeOptionsThemes,
|
||||
type ShikiTransformer,
|
||||
type CodeOptionsMeta,
|
||||
type HighlighterCoreOptions,
|
||||
type CodeToHastOptionsCommon,
|
||||
type RegexEngine,
|
||||
type Awaitable,
|
||||
} from 'shiki';
|
||||
import type { BundledTheme } from 'shiki/themes';
|
||||
import { type Components, toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
||||
@@ -33,9 +34,9 @@ export const defaultThemes = {
|
||||
};
|
||||
|
||||
export type HighlightOptions = CodeToHastOptionsCommon<BundledLanguage> &
|
||||
Pick<HighlighterCoreOptions, 'engine'> &
|
||||
Partial<CodeOptionsThemes<BundledTheme>> &
|
||||
(CodeOptionsThemes<BundledTheme> | Record<never, never>) &
|
||||
CodeOptionsMeta & {
|
||||
engine?: Awaitable<RegexEngine>;
|
||||
components?: Partial<Components>;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
type ReactNode,
|
||||
use,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
@@ -58,7 +59,10 @@ export function useShiki(
|
||||
},
|
||||
deps?: DependencyList,
|
||||
): ReactNode {
|
||||
const key = deps ? JSON.stringify(deps) : `${options.lang}:${code}`;
|
||||
const key = useMemo(
|
||||
() => (deps ? JSON.stringify(deps) : `${options.lang}:${code}`),
|
||||
[code, deps, options.lang],
|
||||
);
|
||||
const shikiOptions = getHighlightOptions(options);
|
||||
const currentTask = useRef<Task | undefined>({
|
||||
key,
|
||||
|
||||
Reference in New Issue
Block a user