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