mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
feat(content-blog): parse date from middle of file path (#6245)
This commit is contained in:
parent
29ecf22409
commit
d133910cb2
6 changed files with 44 additions and 18 deletions
|
@ -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',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue