Skip to content

Commit 8a06eda

Browse files
committed
fix format with locale
1 parent 9edff50 commit 8a06eda

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/[lang]/posts/page.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22
import { format, parseISO } from "date-fns";
3+
import { enUS, zhTW, Locale as DFLocale } from "date-fns/locale";
34
import Link from "next/link";
45
import {
56
allPostsNewToOld,
@@ -10,6 +11,11 @@ import React from "react";
1011
import { Locale } from "i18n-config";
1112
import { getDictionary } from "get-dictionary";
1213

14+
const LocaleFromLang: { [k in Locale]: DFLocale } = {
15+
en: enUS,
16+
"zh-tw": zhTW,
17+
};
18+
1319
function useSelectedTags() {
1420
const [chosen_tags, set_chosen_tags] = React.useState<string[]>([]);
1521
return { chosen_tags, set_chosen_tags };
@@ -126,7 +132,9 @@ export default function PostPage({ params }: { params: { lang: Locale } }) {
126132
<PostNav
127133
title={post.title}
128134
pinned={post.pinned ?? false}
129-
subtitle={format(parseISO(post.date), "LLLL d, yyyy")}
135+
subtitle={format(parseISO(post.date), "LLLL d, yyyy", {
136+
locale: LocaleFromLang[params.lang],
137+
})}
130138
tags={post.tags}
131139
content={post.description}
132140
buttonName="Go to"

0 commit comments

Comments
 (0)