mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-06 17:16:53 -06:00
Attempt client handling of post datetime
This commit is contained in:
14
src/components/Time.tsx
Normal file
14
src/components/Time.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { format } from "date-fns";
|
||||||
|
import type { FunctionComponent } from "react";
|
||||||
|
|
||||||
|
type TimeProps = {
|
||||||
|
time: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Time: FunctionComponent<TimeProps> = ({ time }) => {
|
||||||
|
return (
|
||||||
|
<time className="font-mono">{format(time, "MM-dd-yyyy HH:mm OOO")}</time>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Time;
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
---
|
---
|
||||||
import General from "@layouts/General.astro";
|
import General from "@layouts/General.astro";
|
||||||
import { type CollectionEntry } from 'astro:content';
|
import Time from "@components/Time.jsx";
|
||||||
import { format } from "date-fns";
|
import { type CollectionEntry } from "astro:content";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
post: CollectionEntry<'blog'>;
|
post: CollectionEntry<"blog">;
|
||||||
}
|
}
|
||||||
const { post } = Astro.props;
|
const { post } = Astro.props;
|
||||||
const { title, pubDate, tags } = post.data;
|
const { title, pubDate, tags } = post.data;
|
||||||
const tagCount = tags.length;
|
const tagCount = tags.length;
|
||||||
---
|
---
|
||||||
|
|
||||||
<General title={title}>
|
<General title={title}>
|
||||||
<div class="max-w-3xl mx-4">
|
<div class="max-w-3xl mx-4">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -18,16 +18,16 @@ const tagCount = tags.length;
|
|||||||
</a>
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
<p class="mt-0 text-sm ml-5">
|
<p class="mt-0 text-sm ml-5">
|
||||||
<a href={post.slug}>
|
<Time time={pubDate} client:load />
|
||||||
<time class="font-mono" datetime="{{ page.date | date: '%Y-%m-%dT%H:%M:%SZ' }}">
|
<span class="space-x-2">
|
||||||
{format(pubDate, "MM-dd-yyyy HH:mm OOO")}
|
{
|
||||||
</time>
|
tags.map((tag, i) =>
|
||||||
</a>
|
// Ignore required due to whitespace sensitive content
|
||||||
<span class="space-x-2">
|
// prettier-ignore
|
||||||
{tags.map((tag, i) => (
|
<><a href={`/tags/${tag}`}>{tag}</a>{i < tagCount - 1 ? "," : ""}</>,
|
||||||
<><a href={`/tags/${tag}`}>{ tag }</a>{ i < tagCount - 1 ? ',' : ''}</>
|
)
|
||||||
))}
|
}
|
||||||
</span>
|
</span>
|
||||||
<article>
|
<article>
|
||||||
<slot />
|
<slot />
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Reference in New Issue
Block a user