feat(content-blog): parse date from middle of file path (#6245)

This commit is contained in:
Joshua Chen 2022-01-20 16:43:00 +08:00 committed by GitHub
parent 29ecf22409
commit d133910cb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 18 deletions

View file

@ -108,4 +108,26 @@ describe('parseBlogFileName', () => {
slug: '/2021/05/12/announcing-docusaurus-two-beta/subfolder/subfile',
});
});
test('parse date in the middle of path', () => {
expect(
parseBlogFileName('team-a/2021/05/12/announcing-docusaurus-two-beta.md'),
).toEqual({
date: new Date('2021-05-12Z'),
text: 'announcing-docusaurus-two-beta',
slug: '/2021/05/12/team-a/announcing-docusaurus-two-beta',
});
});
test('parse date in the middle of a folder name', () => {
expect(
parseBlogFileName(
'team-a-2021-05-12-hey/announcing-docusaurus-two-beta.md',
),
).toEqual({
date: new Date('2021-05-12Z'),
text: 'hey/announcing-docusaurus-two-beta',
slug: '/2021/05/12/team-a-hey/announcing-docusaurus-two-beta',
});
});
});