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

feat(v2): allow hiding docs table of contents #2012

Merged
merged 2 commits into from
Nov 19, 2019
Merged

Conversation

yangshun
Copy link
Contributor

Motivation

I want to be able to hide the table of contents for Infima docs where the main content width is not wide enough. Example: https://facebookincubator.github.io/infima/docs/layout/grid

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Screen Shot 2019-11-18 at 9 38 06 PM

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 19, 2019
@yangshun yangshun added pr: new feature This PR adds a new API or behavior. and removed CLA Signed Signed Facebook CLA labels Nov 19, 2019
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Nov 19, 2019

Deploy preview for docusaurus-2 ready!

Built with commit 5614e25

https://deploy-preview-2012--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Nov 19, 2019

Deploy preview for docusaurus-preview ready!

Built with commit 5614e25

https://deploy-preview-2012--docusaurus-preview.netlify.com

Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about accessing it in the UI through frontmatter instead ? Its very coupled to theme.

docusaurus/mdx-loader also exports frontmatter, and I think there isnt much server side processing done for it to be put in metadata

@endiliey
Copy link
Contributor

endiliey commented Nov 19, 2019

In fact, I moved hide_title in my docs versioning PR which includes major performance gain on metadata processing. https://github.com/facebook/docusaurus/pull/1983/files

const {
frontMatter: {hide_title: hideTitle},
} = DocContent;

Currently, our metadata has a lot of dynamic object construction like using delete.
Example:
In the below example, delete o.x does a lot more harm than good behind the scenes, as it changes o’s hidden class and makes it a generic slow object.

var o = { x: 1 };
delete o.x; // true
o.x; // undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants