Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Custom frontmatter/metadata is no longer available #2075

Closed
binarylogic opened this issue Dec 2, 2019 · 5 comments
Closed

[V2] Custom frontmatter/metadata is no longer available #2075

binarylogic opened this issue Dec 2, 2019 · 5 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@binarylogic
Copy link
Contributor

binarylogic commented Dec 2, 2019

🐛 Bug Report

Custom frontmatter/metadata defined in markdown files is no longer accessible within the DocItem component when it previously was.

It appears this change broke the behavior.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Add a custom frontmatter field in a blog post or documentation markdown file.
  2. The property is no longer available in this object.

Expected behavior

Frontmatter, by nature, should allow for a variety of keys, especially a platform designed to serve a variety of different project types.

@binarylogic binarylogic added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Dec 2, 2019
@endiliey
Copy link
Contributor

endiliey commented Dec 2, 2019

Its not a bug. Its actually a bug that got fixed.

expect(data['unrelated_frontmatter']).toBeUndefined();

Its never been documented anyway that you can access frontmatter through metadata. Even in v1 it will throw error if you add unsupported field.

You should not access frontmatter from metadata. Metadata is something done by plugin.

Example: /docs/guides/hello.md defined with frontmatter id: “hello” will have a metadata.id of “guides/hello”

If you want to access frontmatter, do it through content.frontmatter

@endiliey
Copy link
Contributor

endiliey commented Dec 2, 2019

reasoning is here

#1450

Clean up blog data props structure by splitting metadata and front matter into two separate props. This is helpful in letting users add whatever they want to the front matter and have it being referenced in blog posts. Metadata is something that is controlled by the plugin. There will not be collisions if we split it up. For blog list pages, I've also cleaned them up a bit and reused the blog item metadata and front matter. It was being duplicated in the list's metadata and the entries 😓

@endiliey
Copy link
Contributor

endiliey commented Dec 2, 2019

Its also clear in the link you showed that

frontmatter is accessible.

@endiliey endiliey closed this as completed Dec 2, 2019
@binarylogic
Copy link
Contributor Author

Thanks, I must have been using an older version of DocItem/index.js because the frontMatter definition was not included.

@yangshun
Copy link
Contributor

yangshun commented Dec 2, 2019

@binarylogic We would discourage swizzling components at this point until we reach beta or even 2.0.0 for this very reason. Apologies for the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants