summaryrefslogtreecommitdiff
path: root/src/components/Markdown.astro
diff options
context:
space:
mode:
authorTomas Bankauskas <tbdizainas@gmail.com>2024-04-09 12:40:31 +0300
committerGitHub <noreply@github.com>2024-04-09 12:40:31 +0300
commit3bebbf00e6f4d33bfacbf38eef73a9ad7f0d9d58 (patch)
tree2fc74dae2e0d554325ec634891f5726d063e7529 /src/components/Markdown.astro
parent4df0e4a754ea5e1fb0d05a4e08a53cd49e9fce16 (diff)
Added Image CDN page (#4)
* added image-cdn * updated image-cdn page, colors, etc * added Markdown.astro and updated styles
Diffstat (limited to 'src/components/Markdown.astro')
-rw-r--r--src/components/Markdown.astro35
1 files changed, 35 insertions, 0 deletions
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);
+---
+
+<div class:list={['markdown', className]} set:html={html} />