mirror of
https://github.com/youwen5/site.git
synced 2025-03-13 02:21:11 -07:00
27 lines
556 B
TypeScript
27 lines
556 B
TypeScript
import type { PageLoad } from './$types.js';
|
|
import { marked } from 'marked';
|
|
import markedKatex from 'marked-katex-extension';
|
|
import markedAlert from 'marked-alert';
|
|
|
|
export const prerender = true;
|
|
|
|
const options = {
|
|
throwOnError: false
|
|
};
|
|
marked.use(markedKatex(options));
|
|
marked.use(markedAlert());
|
|
|
|
export const load: PageLoad = async ({ fetch }) => {
|
|
try {
|
|
const data = await fetch('/test.md');
|
|
const markdown = await marked.parse(await data.text());
|
|
|
|
return {
|
|
markdown
|
|
};
|
|
} catch (e) {
|
|
return {
|
|
markdown: `Error: ${e}`
|
|
};
|
|
}
|
|
};
|