记录一下在使用astro-paper过程中遇到的问题
Table of contents
Open Table of contents
文章日期比pubDatetime多了8小时
这是因为astro在读取时间时,自动转成了UTC时间,需要指定UTC0时区
修改:
// src/components/Datetime.tsx
const date = myDatetime.toLocaleDateString(LOCALE.langTag, {
year: "numeric",
month: "short",
day: "numeric",
});
const time = myDatetime.toLocaleTimeString(LOCALE.langTag, {
hour: "2-digit",
minute: "2-digit",
});
// 改成
const date = myDatetime.toLocaleDateString(LOCALE.langTag, {
year: "numeric",
month: "short",
day: "numeric",
timeZone: "Europe/London"
});
const time = myDatetime.toLocaleTimeString(LOCALE.langTag, {
hour: "2-digit",
minute: "2-digit",
timeZone: "Europe/London"
});