summaryrefslogtreecommitdiff
path: root/src/components/organisms
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/organisms')
-rw-r--r--src/components/organisms/ActiveLink.astro18
-rw-r--r--src/components/organisms/Date.astro14
-rw-r--r--src/components/organisms/KeywordsList.astro31
3 files changed, 63 insertions, 0 deletions
diff --git a/src/components/organisms/ActiveLink.astro b/src/components/organisms/ActiveLink.astro
new file mode 100644
index 0000000..8c01f92
--- /dev/null
+++ b/src/components/organisms/ActiveLink.astro
@@ -0,0 +1,18 @@
+---
+import type { HTMLAttributes } from "astro/types";
+
+type Props = HTMLAttributes<"a">;
+
+const { href, class: className, ...props } = Astro.props;
+const pathname = Astro.url.pathname;
+const isActive = href === pathname;
+---
+
+<a {href} class:list={[className, { current: isActive }]} {...props}>
+ <slot />
+</a>
+<style>
+ a.current {
+ font-weight: bolder;
+ }
+</style>
diff --git a/src/components/organisms/Date.astro b/src/components/organisms/Date.astro
new file mode 100644
index 0000000..a8b643d
--- /dev/null
+++ b/src/components/organisms/Date.astro
@@ -0,0 +1,14 @@
+---
+interface Props {
+ date: Date;
+ locales: Intl.LocalesArgument;
+ options: Intl.DateTimeFormatOptions;
+}
+
+const { date, locales, options } = Astro.props;
+
+const datetime = date.toISOString();
+const format = new Intl.DateTimeFormat(locales, options).format(date);
+---
+
+<date {datetime}>{format}</date>
diff --git a/src/components/organisms/KeywordsList.astro b/src/components/organisms/KeywordsList.astro
new file mode 100644
index 0000000..4d4b140
--- /dev/null
+++ b/src/components/organisms/KeywordsList.astro
@@ -0,0 +1,31 @@
+---
+interface Props {
+ keywords: string[];
+}
+
+const { keywords } = Astro.props;
+---
+
+<p>
+ {keywords.map((x) => <span>#<b>{x}</b></span>)}
+</p>
+
+<style>
+ p {
+ display: flex;
+ flex-direction: row-reverse;
+ flex-wrap: wrap;
+ gap: calc(var(--size-0) * 1em);
+
+ & > * {
+ border-radius: calc(infinity * 1px);
+ background-color: color-mix(
+ in srgb,
+ var(--color-active) 10%,
+ transparent
+ );
+ color: var(--color-active);
+ padding-inline: calc(var(--size-2) * 1em);
+ }
+ }
+</style>