From 3bebbf00e6f4d33bfacbf38eef73a9ad7f0d9d58 Mon Sep 17 00:00:00 2001 From: Tomas Bankauskas Date: Tue, 9 Apr 2024 12:40:31 +0300 Subject: Added Image CDN page (#4) * added image-cdn * updated image-cdn page, colors, etc * added Markdown.astro and updated styles --- src/components/Markdown.astro | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/components/Markdown.astro (limited to 'src/components/Markdown.astro') diff --git a/src/components/Markdown.astro b/src/components/Markdown.astro new file mode 100644 index 0000000..d9881a8 --- /dev/null +++ b/src/components/Markdown.astro @@ -0,0 +1,35 @@ +--- +import { Marked } from 'marked'; +import markedShiki from 'marked-shiki'; +import { getHighlighter } from 'shiki'; + +interface Props { + content: string; + class?: string; +} + +const { content, class: className } = Astro.props; + +// `getHighlighter` is async, it initializes the internal and +// loads the languages and themes specified. +// Then later you can use `highlighter.codeToHtml` synchronously +// with the loaded themes and languages. +const highlighter = await getHighlighter({ + langs: ['jsx', 'js'], + themes: ['poimandres'] +}); +const html = await new Marked() + .use( + markedShiki({ + highlight(code, lang, props) { + return highlighter.codeToHtml(code, { + lang, + theme: 'poimandres' + }); + } + }) + ) + .parse(content); +--- + +
-- cgit v1.2.3