Skip to content

Commit

Permalink
fix: preload shiki lang
Browse files Browse the repository at this point in the history
  • Loading branch information
blucas.wu committed Oct 12, 2023
1 parent e809eb1 commit 81fab1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/components/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ import { useAsyncEffect } from 'ahooks';

interface Props {
code: string;
codeType?: string;
showCopy?: boolean;
}

export const CodeBlock = ({
code,
codeType = 'language-html',
showCopy = true,
}: Props) => {
export const CodeBlock = ({ code, showCopy = true }: Props) => {
const [codeContent, setCodeContent] = useState('');
useAsyncEffect(async () => {
const highlighter = await sh.get();
const highlighter = await sh.get({
lang: 'html',
});
const content = highlighter.codeToHtml(code, {
lang: 'html',
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/InjectSDK/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const InjectSDKModal = ({
<p className="inject-steps__title">
{index + 1}. {title}
</p>
<CodeBlock code={code} codeType="language-javascript" />
<CodeBlock code={code} />
</div>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SDKPanel = () => {
<p className="sdk-step__title">
{index + 1}. {title}
</p>
<CodeBlock code={code} codeType="language-javascript" />
<CodeBlock code={code} />
</div>
);
})}
Expand Down

0 comments on commit 81fab1c

Please sign in to comment.