Skip to content

Commit

Permalink
fix format with locale
Browse files Browse the repository at this point in the history
  • Loading branch information
algasami committed May 29, 2024
1 parent 9edff50 commit 8a06eda
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/[lang]/posts/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import { format, parseISO } from "date-fns";
import { enUS, zhTW, Locale as DFLocale } from "date-fns/locale";
import Link from "next/link";
import {
allPostsNewToOld,
Expand All @@ -10,6 +11,11 @@ import React from "react";
import { Locale } from "i18n-config";
import { getDictionary } from "get-dictionary";

const LocaleFromLang: { [k in Locale]: DFLocale } = {
en: enUS,
"zh-tw": zhTW,
};

function useSelectedTags() {
const [chosen_tags, set_chosen_tags] = React.useState<string[]>([]);
return { chosen_tags, set_chosen_tags };
Expand Down Expand Up @@ -126,7 +132,9 @@ export default function PostPage({ params }: { params: { lang: Locale } }) {
<PostNav
title={post.title}
pinned={post.pinned ?? false}
subtitle={format(parseISO(post.date), "LLLL d, yyyy")}
subtitle={format(parseISO(post.date), "LLLL d, yyyy", {
locale: LocaleFromLang[params.lang],
})}
tags={post.tags}
content={post.description}
buttonName="Go to"
Expand Down

0 comments on commit 8a06eda

Please sign in to comment.