summaryrefslogtreecommitdiff
path: root/src/components/note/Note.astro
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-03 10:56:21 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-03 10:56:21 +0300
commit456cf011b36de91c9936994b1fa45703adcd309b (patch)
tree8e60daf998f731ac50d100fa490eaecae1168042 /src/components/note/Note.astro
Initial fork of chrismwilliams/astro-theme-cactus theme
Diffstat (limited to 'src/components/note/Note.astro')
-rw-r--r--src/components/note/Note.astro48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/components/note/Note.astro b/src/components/note/Note.astro
new file mode 100644
index 0000000..cff3414
--- /dev/null
+++ b/src/components/note/Note.astro
@@ -0,0 +1,48 @@
+---
+import { type CollectionEntry, render } from "astro:content";
+import FormattedDate from "@/components/FormattedDate.astro";
+import type { HTMLTag, Polymorphic } from "astro/types";
+
+type Props<Tag extends HTMLTag> = Polymorphic<{ as: Tag }> & {
+ note: CollectionEntry<"note">;
+ isPreview?: boolean | undefined;
+};
+
+const { as: Tag = "div", note, isPreview = false } = Astro.props;
+const { Content } = await render(note);
+---
+
+<article
+ class:list={[
+ isPreview && "inline-grid rounded-md bg-[rgb(240,240,240)] px-4 py-3 dark:bg-[rgb(33,35,38)]",
+ ]}
+ data-pagefind-body={isPreview ? false : true}
+>
+ <Tag class="title" class:list={{ "text-base": isPreview }}>
+ {
+ isPreview ? (
+ <a class="cactus-link" href={`/notes/${note.id}/`}>
+ {note.data.title}
+ </a>
+ ) : (
+ <>{note.data.title}</>
+ )
+ }
+ </Tag>
+ <FormattedDate
+ dateTimeOptions={{
+ hour: "2-digit",
+ minute: "2-digit",
+ year: "2-digit",
+ month: "2-digit",
+ day: "2-digit",
+ }}
+ date={note.data.publishDate}
+ />
+ <div
+ class="prose prose-sm prose-cactus mt-4 max-w-none [&>p:last-of-type]:mb-0"
+ class:list={{ "line-clamp-6": isPreview }}
+ >
+ <Content />
+ </div>
+</article>