···
1
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
18
-
// Highlight the JSON with Catppuccin Latte
19
19
-
const highlightedPropsJson = await codeToHtml(
20
20
-
JSON.stringify(props, null, 2),
21
21
-
{
22
22
-
lang: 'json',
23
23
-
theme: 'catppuccin-latte'
24
24
-
}
25
25
-
);
17
17
+
let highlightedPropsJson: string;
18
18
+
19
19
+
try {
20
20
+
// Try to use Shiki for syntax highlighting
21
21
+
const { codeToHtml } = await import('shiki');
22
22
+
highlightedPropsJson = await codeToHtml(
23
23
+
JSON.stringify(props, null, 2),
24
24
+
{
25
25
+
lang: 'json',
26
26
+
theme: 'catppuccin-latte'
27
27
+
}
28
28
+
);
29
29
+
} catch (error) {
30
30
+
// Fallback to plain HTML with <pre> if Shiki fails (e.g., in Cloudflare Workers)
31
31
+
console.warn('Shiki highlighting failed, using plain text fallback:', error);
32
32
+
highlightedPropsJson = `<pre><code>${JSON.stringify(props, null, 2)}</code></pre>`;
33
33
+
}
26
34
27
35
return {
28
36
...props,