Skip to content

Commit

Permalink
⚡ perf: 提升 shiki 加载速度
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed May 26, 2023
1 parent 9619614 commit 3466076
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Highlighter/useShiki.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { getHighlighter, Highlighter, Theme } from 'shiki-es';
import { Highlighter, Theme, getHighlighter, setCDN } from 'shiki-es';
import useControlledState from 'use-merge-value';

import { languageMap } from './language';
Expand All @@ -15,6 +15,9 @@ export interface ShikiOptions {
theme?: Partial<ShikiSyntaxTheme>;
}

// 使用 element cdn 提升加载速度
setCDN('https://npm.elemecdn.com/shiki-es/dist/assets');

const defaultTheme: ShikiSyntaxTheme = {
dark: 'github-dark',
light: 'github-light',
Expand Down

1 comment on commit 3466076

@vercel
Copy link

@vercel vercel bot commented on 3466076 May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.