[READ-ONLY] Mirror of https://github.com/mrgnw/ananas. learn multiple languages at once ananas.xcc.es
0

Configure Feed

Select the types of activity you want to include in your feed.

shiki fallback

+17 -9
+17 -9
src/routes/debug/+page.server.ts
··· 1 - import { codeToHtml } from 'shiki'; 2 1 import type { PageServerLoad } from './$types'; 3 2 4 3 export const load: PageServerLoad = async ({ url, request, locals, params }) => { ··· 15 14 userPreferences: locals.userPreferences || null 16 15 }; 17 16 18 - // Highlight the JSON with Catppuccin Latte 19 - const highlightedPropsJson = await codeToHtml( 20 - JSON.stringify(props, null, 2), 21 - { 22 - lang: 'json', 23 - theme: 'catppuccin-latte' 24 - } 25 - ); 17 + let highlightedPropsJson: string; 18 + 19 + try { 20 + // Try to use Shiki for syntax highlighting 21 + const { codeToHtml } = await import('shiki'); 22 + highlightedPropsJson = await codeToHtml( 23 + JSON.stringify(props, null, 2), 24 + { 25 + lang: 'json', 26 + theme: 'catppuccin-latte' 27 + } 28 + ); 29 + } catch (error) { 30 + // Fallback to plain HTML with <pre> if Shiki fails (e.g., in Cloudflare Workers) 31 + console.warn('Shiki highlighting failed, using plain text fallback:', error); 32 + highlightedPropsJson = `<pre><code>${JSON.stringify(props, null, 2)}</code></pre>`; 33 + } 26 34 27 35 return { 28 36 ...props,