Skip to content

Commit

Permalink
update api, add passing format options
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed Aug 16, 2023
1 parent 2258588 commit bd5f0dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/components/FormattedDate.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import type { HTMLAttributes } from "astro/types";
import { getFormattedDate } from "@/utils";
interface Props {
type Props = HTMLAttributes<"time"> & {
date: Date;
className?: HTMLAttributes<"time">["class"];
}
dateTimeOptions?: Intl.DateTimeFormatOptions;
};
const { date, className = null } = Astro.props;
const { date, dateTimeOptions, ...attrs } = Astro.props;
const postDate = getFormattedDate(date, { month: "long" });
const postDate = getFormattedDate(date, dateTimeOptions);
---

<time class={className} datetime={date.toISOString()}>
<time datetime={date.toISOString()} {...attrs}>
{postDate}
</time>
2 changes: 1 addition & 1 deletion src/components/blog/PostPreview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { post, as: Tag = "div", withDesc = false } = Astro.props;
const postDate = post.data.updatedDate ?? post.data.publishDate;
---

<FormattedDate date={postDate} className="min-w-[120px] text-gray-500" />
<FormattedDate date={postDate} class="min-w-[120px] text-gray-500" />
<Tag>
<a href={`/posts/${post.slug}/`} class="cactus-link" rel="prefetch">
{post.data.title}
Expand Down

0 comments on commit bd5f0dd

Please sign in to comment.