File tree Expand file tree Collapse file tree
routes/(app)/content/themes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121 "@iconify-json/simple-icons" : " catalog:" ,
2222 "@lucide/svelte" : " catalog:" ,
2323 "@neondatabase/serverless" : " catalog:" ,
24+ "@shikijs/core" : " catalog:" ,
25+ "@shikijs/engine-javascript" : " catalog:" ,
26+ "@shikijs/langs" : " catalog:" ,
27+ "@shikijs/themes" : " catalog:" ,
28+ "@shikijs/types" : " catalog:" ,
2429 "@skeletonlabs/skeleton" : " workspace:*" ,
2530 "@skeletonlabs/skeleton-svelte" : " workspace:*" ,
2631 "@sveltejs/adapter-vercel" : " catalog:" ,
Original file line number Diff line number Diff line change 1+ /* Generate by @shikijs/codegen */
2+ import { createSingletonShorthands , createBundledHighlighter } from '@shikijs/core' ;
3+ import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript' ;
4+ import type { DynamicImportLanguageRegistration , DynamicImportThemeRegistration } from '@shikijs/types' ;
5+
6+ type BundledLanguage = 'ts' | 'tsx' | 'svelte' ;
7+ type BundledTheme = 'github-light' | 'github-dark' ;
8+
9+ const bundledLanguages = {
10+ ts : ( ) => import ( '@shikijs/langs/typescript' ) ,
11+ tsx : ( ) => import ( '@shikijs/langs/tsx' ) ,
12+ svelte : ( ) => import ( '@shikijs/langs/svelte' ) ,
13+ } satisfies Record < BundledLanguage , DynamicImportLanguageRegistration > ;
14+
15+ const bundledThemes = {
16+ 'github-light' : ( ) => import ( '@shikijs/themes/github-light' ) ,
17+ 'github-dark' : ( ) => import ( '@shikijs/themes/github-dark' ) ,
18+ } satisfies Record < BundledTheme , DynamicImportThemeRegistration > ;
19+
20+ const createHighlighter = /* @__PURE__ */ createBundledHighlighter < BundledLanguage , BundledTheme > ( {
21+ langs : bundledLanguages ,
22+ themes : bundledThemes ,
23+ engine : ( ) => createJavaScriptRegexEngine ( ) ,
24+ } ) ;
25+
26+ export const { codeToHtml } = /* @__PURE__ */ createSingletonShorthands < BundledLanguage , BundledTheme > ( createHighlighter ) ;
Original file line number Diff line number Diff line change 1+ <script lang =" ts" module >
2+ export interface Props {
3+ code: Parameters <typeof codeToHtml >[0 ];
4+ lang: Parameters <typeof codeToHtml >[1 ][' lang' ];
5+ }
6+ </script >
7+
8+ <script lang =" ts" >
9+ import { codeToHtml } from ' $lib/code-highlight/shiki.bundle' ;
10+
11+ const { code, lang }: Props = $props ();
12+
13+ const html = $derived (
14+ await codeToHtml (code , {
15+ lang ,
16+ themes: {
17+ light: ' github-light' ,
18+ dark: ' github-dark' ,
19+ },
20+ defaultColor: ' light-dark()' ,
21+ }),
22+ );
23+ </script >
24+
25+ {@html html }
Original file line number Diff line number Diff line change 1+ <script >
2+ import Code from ' $lib/components/code/code.svelte' ;
3+ </script >
4+
15<div class =" container-page" >
26 <p >Now viewing <code class =" code" >themes (repo)</code ></p >
7+
8+ <Code code =" console.log('Hello, World!');" lang =" ts" />
39</div >
You can’t perform that action at this time.
0 commit comments