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): auto-generated sidebars, frontmatter-less sites #4582

Merged
merged 53 commits into from
Apr 15, 2021

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Apr 6, 2021

Motivation

Fixes #3464

Good description of this PR here: #3464 (comment)

  • Make it easy to create a site without any sidebar, and infer the sidebar from the FS structure
  • Make it easy to have no frontmatter at all, and derive good metadata from FS naming conventions (file number prefixes)

Breaking changes:

  • A site without sidebars file will now autogenerate a sidebar automatically from the docs folder. Use an empty sidebars file if you want no sidebar at all.
  • By default, we strip numbers in front of folders/filenames, as numbers prefixes are often used to provide docs order: this could have unintended side-effects if you have existing docs starting with numbers.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

tests, preview, dogfooding

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Apr 6, 2021
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 6, 2021
@netlify
Copy link

netlify bot commented Apr 6, 2021

[V1]

Built with commit f23e823

https://deploy-preview-4582--docusaurus-1.netlify.app

@github-actions
Copy link

github-actions bot commented Apr 6, 2021

Size Change: +33 B (0%)

Total Size: 598 kB

Filename Size Change
website/build/assets/js/main.********.js 422 kB +33 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/build/assets/css/styles.********.css 87.2 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus/index.html 62.1 kB 0 B
website/build/docs/introduction/index.html 235 B 0 B
website/build/index.html 26.9 kB 0 B

compressed-size-action

@netlify
Copy link

netlify bot commented Apr 6, 2021

[V2]

Built with commit f23e823

https://deploy-preview-4582--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Apr 7, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 85
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4582--docusaurus-2.netlify.app/

@slorber slorber added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Apr 7, 2021
@slorber slorber changed the title feat(v2): auto-generated sidebars feat(v2): auto-generated sidebars, frontmatter-less sites Apr 9, 2021
@slorber slorber marked this pull request as ready for review April 13, 2021 10:45
@slorber slorber requested a review from lex111 as a code owner April 13, 2021 10:45
@ywjr
Copy link

ywjr commented Apr 30, 2021

Generating sidebar automatically is a good function. I suggest that when generating sidebar automatically, the system can add filtering rules to filter out some files (such as readme. md

@borekb
Copy link

borekb commented May 12, 2021

By default, we strip numbers in front of folders/filenames, as numbers prefixes are often used to provide docs order: this could have unintended side-effects if you have existing docs starting with numbers.

(emphasis mine) @slorber That is very true for us 😄. We have a numbered tutorial like this:

  • 01-intro
  • 02-build-ui
  • 03-fetch-data
  • etc.

The files keep working as 01-intro.md but URLs are suddenly without these numbers, leading to 404s 🙁.

Any way to work around this?

@slorber
Copy link
Collaborator Author

slorber commented May 12, 2021

@borekb not sure to understand why you want the numbers in the URLs?

In any case, you should be able to use a custom slug to add these numbers back, or simply disable the feature with numberPrefixParser: false in the docs plugin/preset config

@borekb
Copy link

borekb commented May 12, 2021

It's just how it was, the tutorial part of our docs site used numbers in the URLs. Thanks for the tip with numberPrefixParser!

@slorber slorber deleted the slorber/autogen-sidebars branch August 17, 2021 17:50
position?: number;
collapsed?: boolean;

// TODO should we allow "items" here? how would this work? would an "autogenerated" type be allowed?
Copy link

Choose a reason for hiding this comment

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

@slorber Assuming based on this that I won't be able to do what I asked about in an earlier comment?
#3464 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No I don't think it's possible atm but we may add support for it if there's a good use-case exposed clearly, preferably with a concrete example showcasing the problem (seeing sources is better)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. pr: new feature This PR adds a new API or behavior.
Projects
None yet
5 participants