summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Alert.astro16
-rw-r--r--src/components/Markdown.astro35
2 files changed, 51 insertions, 0 deletions
diff --git a/src/components/Alert.astro b/src/components/Alert.astro
new file mode 100644
index 0000000..1a468fb
--- /dev/null
+++ b/src/components/Alert.astro
@@ -0,0 +1,16 @@
+---
+interface Props {
+ class?: string;
+}
+
+const { class: className } = Astro.props;
+---
+
+<div class:list={['alert alert-info', className].join(' ')}>
+ <svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 fill-current shrink-0" viewBox="0 0 24 24">
+ <path
+ d="M12 20.016q3.281 0 5.648-2.367t2.367-5.648-2.367-5.648-5.648-2.367-5.648 2.367-2.367 5.648 2.367 5.648 5.648 2.367zM12 2.016q4.125 0 7.055 2.93t2.93 7.055-2.93 7.055-7.055 2.93-7.055-2.93-2.93-7.055 2.93-7.055 7.055-2.93zM11.016 6.984h1.969v6h-1.969v-6zM11.016 15h1.969v2.016h-1.969v-2.016z"
+ ></path>
+ </svg>
+ <slot />
+</div>
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} />