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

isCategoryIndex function does not propagate to URL generations #9213

Closed
6 of 7 tasks
anaclumos opened this issue Aug 8, 2023 · 4 comments
Closed
6 of 7 tasks

isCategoryIndex function does not propagate to URL generations #9213

anaclumos opened this issue Aug 8, 2023 · 4 comments
Labels
closed: working as intended This issue is intended behavior, there's no need to take any action.

Comments

@anaclumos
Copy link
Contributor

anaclumos commented Aug 8, 2023

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I have set up

isCategoryIndex() {
  return false
},

for my docusaurus.config.js. And I have a folder structure of

08
├── 01.md
├── 02.md
├── 03.md
├── 04.md
├── 05.md
├── 06.md
├── 07.md
└── 08.md

As a folder structure of docs/2023/08. As you can see, it's just a calendar notation. However, while isCategoryIndex disables the sidebar behavior of overriding 'August 8th' to August, it still creates the URL for 2023/08.

Reproducible demo

https://github.com/anaclumos/heimdall/tree/da910b28b2ae2d6ecf77225db38035e57cdaa637 (Exact Commit)

Steps to reproduce

https://github.com/anaclumos/heimdall/tree/da910b28b2ae2d6ecf77225db38035e57cdaa637 (Exact Commit)

Expected behavior

The URL for docs/2023/08/08.md should be generated at sitename/2023/08/08, not sitename/2023/08

Actual behavior

The URL generates at sitename/2023/08

Your environment

No response

Self-service

  • I'd be willing to fix this bug myself.
@anaclumos anaclumos 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 Aug 8, 2023
@Josh-Cena
Copy link
Collaborator

Hi, this is deliberate by design. See #6451 (comment). You would want to use the slug front matter instead.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2023
@Josh-Cena Josh-Cena added closed: working as intended This issue is intended behavior, there's no need to take any action. and removed 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 Aug 8, 2023
@anaclumos
Copy link
Contributor Author

If because category index pages are not coupled to the slug system and we'd better not give users the impression that they are, would there be an exposed function for isSlugIndex or so? I am generating many pages (thousands) and want as minimum information as possible.

@Josh-Cena
Copy link
Collaborator

This would be possible with the createFrontMatter hook: #5568

@slorber
Copy link
Collaborator

slorber commented Aug 9, 2023

Yes, solving your use-case would be quite complicated. And a breaking change too (it's always quite risky for our users to change the permalink generation algo).

Currently the process is:

  • Read docs files, generate metadata including a permalink for each
  • Generate the autogenerated sidebar from those docs

Providing an explicit slug remains an option, although not as convenient.

And createFrontMatter would also give you the ability to generate with code your own slug front matter.

Another option would allow to allow providing a isCategoryIndex callback as a first-class docs plugin option, and default to the current behavior. This would be the default isCategoryIndex that is passed as param to the defaultSidebarItemsGenerator. Once we have createFrontMatter, I'm not sure it would be a super useful option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: working as intended This issue is intended behavior, there's no need to take any action.
Projects
None yet
Development

No branches or pull requests

3 participants