feat(content-blog): include front matter in loaded content metadata (#6189)

* feat(content-blog): include front matter in metadata

* fixes
This commit is contained in:
Joshua Chen 2021-12-26 11:24:24 +08:00 committed by GitHub
parent e1bff072fe
commit 2cc89e502f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 0 deletions

View file

@ -126,6 +126,9 @@ describe('loadBlog', () => {
authors: [],
date: new Date('2019-01-01'),
formattedDate: 'January 1, 2019',
frontMatter: {
date: new Date('2019-01-01'),
},
prevItem: undefined,
tags: [],
nextItem: {
@ -161,6 +164,15 @@ describe('loadBlog', () => {
],
date: new Date('2018-12-14'),
formattedDate: 'December 14, 2018',
frontMatter: {
authors: [
{
name: 'Yangshun Tay (translated)',
},
'slorber',
],
title: 'Happy 1st Birthday Slash! (translated)',
},
tags: [],
prevItem: {
permalink: '/blog/date-matter',
@ -187,6 +199,11 @@ describe('loadBlog', () => {
},
date: new Date('2020-08-16'),
formattedDate: 'August 16, 2020',
frontMatter: {
date: new Date('2020-08-16'),
slug: '/hey/my super path/héllô',
title: 'Complex Slug',
},
tags: [],
truncated: false,
});
@ -216,6 +233,14 @@ describe('loadBlog', () => {
},
date: new Date('2020-08-15'),
formattedDate: 'August 15, 2020',
frontMatter: {
author: 'Sébastien Lorber',
author_title: 'Docusaurus maintainer',
author_url: 'https://sebastienlorber.com',
date: new Date('2020-08-15'),
slug: '/simple/slug',
title: 'Simple Slug',
},
tags: [],
truncated: false,
});
@ -233,6 +258,9 @@ describe('loadBlog', () => {
authors: [],
date: new Date('2019-01-02'),
formattedDate: 'January 2, 2019',
frontMatter: {
date: new Date('2019-01-02'),
},
prevItem: undefined,
tags: [],
nextItem: {
@ -388,6 +416,7 @@ describe('loadBlog', () => {
authors: [],
date: noDateSourceBirthTime,
formattedDate,
frontMatter: {},
tags: [],
prevItem: undefined,
nextItem: undefined,

View file

@ -234,6 +234,7 @@ async function processBlogSourceFile(
: undefined,
truncated: truncateMarker?.test(content) || false,
authors,
frontMatter,
},
content,
};

View file

@ -43,6 +43,7 @@ declare module '@theme/BlogPostPage' {
readonly nextItem?: {readonly title: string; readonly permalink: string};
readonly prevItem?: {readonly title: string; readonly permalink: string};
readonly authors: import('./types').Author[];
readonly frontMatter: FrontMatter & Record<string, unknown>;
readonly tags: readonly {
readonly label: string;
readonly permalink: string;

View file

@ -160,6 +160,7 @@ export interface MetaData {
truncated: boolean;
editUrl?: string;
authors: Author[];
frontMatter: BlogPostFrontMatter & Record<string, unknown>;
}
export interface Assets {