feat(v2): include frontmatter in loadedContent doc metadatas (#4495)

* feat: include frontmatter in globals

* feat: include frontmatter in globals (options schema test)

* feat(v2): document frontmatter in document metadata

* feat(v2): frontmatter in metadata, tests updated

* Update packages/docusaurus-plugin-content-docs/src/types.ts

* Update packages/docusaurus-plugin-content-docs/src/types.ts

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
Chris Kanich 2021-03-26 13:54:29 -05:00 committed by GitHub
parent 9715048f79
commit b10ed6cb00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 192 additions and 22 deletions

View file

@ -262,6 +262,10 @@ describe('simple website', () => {
),
title: 'Hello, World !',
description: 'Hi, Endilie here :)',
frontMatter: {
id: 'hello',
title: 'Hello, World !',
},
});
expect(findDocById(currentVersion, 'foo/bar')).toEqual({
@ -285,6 +289,11 @@ describe('simple website', () => {
),
title: 'Bar',
description: 'This is custom description',
frontMatter: {
description: 'This is custom description',
id: 'bar',
title: 'Bar',
},
});
expect(currentVersion.sidebars).toMatchSnapshot();
@ -433,6 +442,9 @@ describe('versioned website', () => {
),
title: 'bar',
description: 'This is next version of bar.',
frontMatter: {
slug: 'barSlug',
},
version: 'current',
sidebar: 'docs',
next: {
@ -454,6 +466,7 @@ describe('versioned website', () => {
),
title: 'hello',
description: 'Hello next !',
frontMatter: {},
version: 'current',
sidebar: 'docs',
previous: {
@ -475,6 +488,7 @@ describe('versioned website', () => {
),
title: 'hello',
description: 'Hello 1.0.1 !',
frontMatter: {},
version: '1.0.1',
sidebar: 'version-1.0.1/docs',
previous: {
@ -498,6 +512,7 @@ describe('versioned website', () => {
title: 'baz',
description:
'Baz 1.0.0 ! This will be deleted in next subsequent versions.',
frontMatter: {},
version: '1.0.0',
sidebar: 'version-1.0.0/docs',
next: {
@ -642,6 +657,7 @@ describe('versioned website (community)', () => {
description: 'Team current version (translated)',
version: 'current',
sidebar: 'community',
frontMatter: {title: 'Team title translated'},
});
expect(findDocById(version100, 'team')).toEqual({
...defaultDocMetadata,
@ -659,6 +675,7 @@ describe('versioned website (community)', () => {
description: 'Team 1.0.0',
version: '1.0.0',
sidebar: 'version-1.0.0/community',
frontMatter: {},
});
expect(currentVersion.sidebars).toMatchSnapshot('current version sidebars');