-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Autogenerated sidebar fails to parse category indeces when categories have non-latin characters #8124
Comments
This appears to only be an issue on Windows. When building on a Unix server (e.g. the public URL) this issue does not reproduce. |
After providing my own presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
/* ... */
async sidebarItemsGenerator({ defaultSidebarItemsGenerator, isCategoryIndex, ...args }) {
const newIsCategoryIndex = (args) => {
const outp = isCategoryIndex(args);
console.log(args, outp);
return outp;
};
const sidebar = defaultSidebarItemsGenerator({
...args,
isCategoryIndex: newIsCategoryIndex,
});
return sidebar;
},
}
}),
],
],
It looks like the |
Thanks for the detailed report and taking time to look into this! We have this weird logic: docusaurus/packages/docusaurus-utils/src/pathUtils.ts Lines 48 to 70 in 6514f07
I don't have access to a Windows device so I can't tell if that logic is still relevant today. Do you have sources on what kind of characters are accepted by Windows if the path is POSIX? |
I do not have any official information, and have been unable to find any. The closest information I've gotten was from the .NET documentation for
Another interesting resource is from IBM, stating that
On an anecdotal basis I can confirm that both import fs from "fs";
console.log(fs.statSync("C:/Users/me/Documents/dev/test/abc/test.txt")); // { ... }
console.log(fs.statSync("C:/Users/me/Documents/dev/test/æøå/test.txt")); // { ... } |
Okay... hmmm... we may be better off normalizing all backslashes. Can simplify a lot of logic. We can see if someone uses arcane characters and complains. |
I have done a bit of digging and found:
That is to say: all Windows paths should support forward slash as path separator, except if it's an extended-length path (identified by the prefix I have asked for the justification of the ASCII limitation in the original project (see sindresorhus/slash#19). |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
The sidebar autogenerator normally checks for category indeces, converting the category into a link if there is nothing but an index in it. It does this by checking if the file is named
"index"
,"readme"
, or the name of the category itself.This process fails if the category has a name that contains non-latin characters, e.g.
"æ"
. In that case the file will not be seen as an index (regardless of its name) [edit: if running on Windows; the issue does not reproduce on Unix]Reproducible demo
https://github.com/birjj/docusaurus-repro-8124
Steps to reproduce
docs
, name it something using only latin characters (e.g.docs/abc
).index.md
(e.g.docs/abc/index.md
). Docusaurus should now show the category as a simple link, sinceindex.md
is seen as the category index, and no other doc is contained in the category.docs/æøå
). Make sure the index file is also copied over (e.g.docs/æå/index
). This folder will not be collapsed, even though the only difference from before is its name.Your
docs
file structure should look like:Expected behavior
The category index should be detected regardless of the category name.
Actual behavior
The category index is not detected for the category with non-latin characters in its name. The category therefore isn't show as a simple link:
Your environment
Self-service
The text was updated successfully, but these errors were encountered: