mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +02:00
fix(content-blog): always convert front matter date as UTC (#6244)
This commit is contained in:
parent
51d391a072
commit
9f0809ae28
1 changed files with 6 additions and 1 deletions
|
@ -160,7 +160,12 @@ async function processBlogSourceFile(
|
|||
async function getDate(): Promise<Date> {
|
||||
// Prefer user-defined date.
|
||||
if (frontMatter.date) {
|
||||
return new Date(frontMatter.date);
|
||||
if (typeof frontMatter.date === 'string') {
|
||||
// Always treat dates as UTC by adding the `Z`
|
||||
return new Date(`${frontMatter.date}Z`);
|
||||
}
|
||||
// YAML only converts YYYY-MM-DD to dates and leaves others as strings.
|
||||
return frontMatter.date;
|
||||
} else if (parsedBlogFileName.date) {
|
||||
return parsedBlogFileName.date;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue