mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 14:06:59 +02:00
feat(v2): read first heading as title and use it in front-matter (#4485)
* feat(v2): read first heading as title and pass it to front-matter * fix(v2): always trim content after extracting front-matter * fix(v2): remove heading from rss and keep duplicate heading * fix(v2): rollback some unnecessary comment changes * test(v2): add unit tests to blog * test(v2): add unit tests to docs * test(v2): correct issue on windows * test(v2): add additional test cases
This commit is contained in:
parent
fb372c574d
commit
ea13c94cc2
16 changed files with 448 additions and 35 deletions
|
@ -0,0 +1 @@
|
|||
# My heading as title
|
|
@ -67,6 +67,11 @@ Object {
|
|||
"path": "/docs/foo/bazSlug.html",
|
||||
"sidebar": "docs",
|
||||
},
|
||||
Object {
|
||||
"id": "headingAsTitle",
|
||||
"path": "/docs/headingAsTitle",
|
||||
"sidebar": undefined,
|
||||
},
|
||||
Object {
|
||||
"id": "hello",
|
||||
"path": "/docs/",
|
||||
|
@ -172,6 +177,17 @@ Object {
|
|||
\\"title\\": \\"Hello, World !\\",
|
||||
\\"permalink\\": \\"/docs/\\"
|
||||
}
|
||||
}",
|
||||
"site-docs-heading-as-title-md-c6d.json": "{
|
||||
\\"unversionedId\\": \\"headingAsTitle\\",
|
||||
\\"id\\": \\"headingAsTitle\\",
|
||||
\\"isDocsHomePage\\": false,
|
||||
\\"title\\": \\"My heading as title\\",
|
||||
\\"description\\": \\"\\",
|
||||
\\"source\\": \\"@site/docs/headingAsTitle.md\\",
|
||||
\\"slug\\": \\"/headingAsTitle\\",
|
||||
\\"permalink\\": \\"/docs/headingAsTitle\\",
|
||||
\\"version\\": \\"current\\"
|
||||
}",
|
||||
"site-docs-hello-md-9df.json": "{
|
||||
\\"unversionedId\\": \\"hello\\",
|
||||
|
@ -383,6 +399,11 @@ Object {
|
|||
"path": "/docs/foo/bazSlug.html",
|
||||
"sidebar": "docs",
|
||||
},
|
||||
Object {
|
||||
"id": "headingAsTitle",
|
||||
"path": "/docs/headingAsTitle",
|
||||
"sidebar": undefined,
|
||||
},
|
||||
Object {
|
||||
"id": "hello",
|
||||
"path": "/docs/",
|
||||
|
@ -494,6 +515,14 @@ Array [
|
|||
},
|
||||
"path": "/docs/foo/bazSlug.html",
|
||||
},
|
||||
Object {
|
||||
"component": "@theme/DocItem",
|
||||
"exact": true,
|
||||
"modules": Object {
|
||||
"content": "@site/docs/headingAsTitle.md",
|
||||
},
|
||||
"path": "/docs/headingAsTitle",
|
||||
},
|
||||
Object {
|
||||
"component": "@theme/DocItem",
|
||||
"exact": true,
|
||||
|
@ -579,6 +608,7 @@ These sidebar document ids do not exist:
|
|||
Available document ids=
|
||||
- foo/bar
|
||||
- foo/baz
|
||||
- headingAsTitle
|
||||
- hello
|
||||
- ipsum
|
||||
- lorem
|
||||
|
|
|
@ -160,6 +160,7 @@ describe('simple site', () => {
|
|||
'rootRelativeSlug.md',
|
||||
'rootResolvedSlug.md',
|
||||
'rootTryToEscapeSlug.md',
|
||||
'headingAsTitle.md',
|
||||
'foo/bar.md',
|
||||
'foo/baz.md',
|
||||
'slugs/absoluteSlug.md',
|
||||
|
|
|
@ -211,6 +211,7 @@ describe('simple website', () => {
|
|||
expect(isMatch('docs/hello.js', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/super.mdl', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/mdx', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/headingAsTitle.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('sidebars.json', matchPattern)).toEqual(true);
|
||||
expect(isMatch('versioned_docs/hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('hello.md', matchPattern)).toEqual(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue