Skip to content

Commit

Permalink
perf(shiki): add optimised shiki bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiguelv committed Jan 24, 2025
1 parent 1d7b9a7 commit af75438
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/src/lib/css/shiki.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[color-scheme='dark'] .shiki,
[color-scheme='dark'] .shiki span {
background-color: var(--shiki-dark-bg) !important;
color: var(--shiki-dark) !important;
}

[color-scheme='dim'] .shiki,
[color-scheme='dim'] .shiki span {
background-color: var(--s-dim-bg) !important;
color: var(--s-dim) !important;
}
44 changes: 44 additions & 0 deletions frontend/src/lib/shiki.bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* Generate by @shikijs/codegen */
import {
createSingletonShorthands,
createdBundledHighlighter,
} from '@shikijs/core'
import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript'

const bundledLanguages = {
xml: () => import('@shikijs/langs/xml'),
}

const bundledThemes = {
'rose-pine-dawn': () => import('@shikijs/themes/rose-pine-dawn'),
'rose-pine-moon': () => import('@shikijs/themes/rose-pine-moon'),
}

const createHighlighter = /* @__PURE__ */ createdBundledHighlighter({
langs: bundledLanguages,
themes: bundledThemes,
engine: () => createJavaScriptRegexEngine(),
})

const {
codeToHtml,
codeToHast,
codeToTokensBase,
codeToTokens,
codeToTokensWithThemes,
getSingletonHighlighter,
getLastGrammarState,
} = /* @__PURE__ */ createSingletonShorthands(createHighlighter)

export {
bundledLanguages,
bundledThemes,
codeToHast,
codeToHtml,
codeToTokens,
codeToTokensBase,
codeToTokensWithThemes,
createHighlighter,
getLastGrammarState,
getSingletonHighlighter,
}

0 comments on commit af75438

Please # to comment.