docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

CustomProps for doc items

Open OdedItkinOW opened this issue 3 years ago • 1 comments

According to the docs (https://docusaurus.io/docs/sidebar/autogenerated#doc-item-metadata), doc items should support the customProps argument, using the sidebar_custom_props frontmatter item. Added support for it to the default generator

Pre-flight checklist

  • [X] I have read the Contributing Guidelines on pull requests.
  • [X] If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • [ ] If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

For a certain website feature, I needed the ability to add customProps to all sidebar items on the website, so I can tag pages more consistently in the navigation. I noticed that the feature itself was documented as supported, but did not work, and then identified the exact piece of code that was missing.

Test Plan

The testing plan was simple - Take an existing passing test for a simple sidebar, copy it, add test custom props to different items of it, and then add those same props to a copy of the resulting snapshot, and check that the two align.

Test links

https://github.com/OdedItkinOW/docusaurus/blob/patch-1/packages/docusaurus-plugin-content-docs/src/sidebars/tests/generator.test.ts

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

OdedItkinOW avatar Oct 27 '22 11:10 OdedItkinOW

[V2]

Built without sensitive environment variables

Name Link
Latest commit 165b6828c352d98a5dbb1aea46fc96a4b30e6573
Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/635a6bb4c6830f0008873d03
Deploy Preview https://deploy-preview-8256--docusaurus-2.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 27 '22 11:10 netlify[bot]