docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

fix(content-docs): use category index convention to infer document title

Open MarkShawn2020 opened this issue 3 years ago • 3 comments

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.
  • [x] 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

I found if I have file path like xx/yy/zz/index.md or xx/yy/zz/readme.md without a 'tittle' frontmatter or '#1' title in the document, then the title of this file shown in the sidebar would be index or readme, which is not desired, since the directory name zz may be more suitable.

Test Plan

Test links

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

Related issues/PRs

MarkShawn2020 avatar Sep 06 '22 12:09 MarkShawn2020

[V2]

Built without sensitive environment variables

Name Link
Latest commit 353a12537b72795e36d3ab9b772af0563d7099f4
Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/63173a4a2937a20008490501
Deploy Preview https://deploy-preview-8052--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 Sep 06 '22 12:09 netlify[bot]

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 73 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 75 🟢 100 🟢 100 🟢 100 🟢 90 Report

github-actions[bot] avatar Sep 06 '22 12:09 github-actions[bot]

Note we already have a convention to detect "category index documents", see

Good job!

We also want to cover such subtle behaviors with unit tests

Sorry to admit that I have few ideas on how to write unit tests for directory strucurues.

Also note that with autogeneated sidebars, folders might have a number prefix for ordering reasons, and you may want to strip that number in the infered title: /xx/yy/03-zz/index.md should infer to zz and not 03-zz? (see impl of getSlug() for inspiration)

Yep!

MarkShawn2020 avatar Sep 08 '22 11:09 MarkShawn2020