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

Inferring "sidebar_position" from the filename #1247

Open
honzajavorek opened this issue Oct 10, 2024 · 4 comments
Open

Inferring "sidebar_position" from the filename #1247

honzajavorek opened this issue Oct 10, 2024 · 4 comments
Labels
t-academy Issues related to Web Scraping and Apify academies. t-docs Issues owned by technical writing team. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@honzajavorek
Copy link
Collaborator

In the Python course, I use the following format for filenames: {sidebar_position}_{slug}.md E.g. the file of the tenth lesson is 10_crawling.md

Would it be a good idea if we added inferring of sidebar_position to Docusaurus? The algorithm would be:

  1. See if sidebar_position is set in the front matter. If yes, respect the value.
  2. If not set, see if the filename starts with r"\d\d_". If yes, take that as the value for sidebar_position.
  3. Otherwise leave sidebar_position unassigned.

Not sure if this is worth the engineering and the cognitive load necessary to understand that this happens (would need to be documented somewhere in contribution docs). But it would help me to keep the values synchronized both in the filename and the front matter.

If I wanted to reorder lessons or add new lesson in between existing ones, I could only change filenames. The way it is now it's easy to forget about the front matter and leave it in disarray by mistake.

At the same time, I find the {sidebar_position}_{slug}.md format of filename highly practical for the purpose of the course. At least subjectively, my orientation in editor and file system is much better this way than with other parts of the Academy where the files are ordered alphabetically on disk, but according to sidebar_position in the docs navigation.

@honzajavorek honzajavorek added t-academy Issues related to Web Scraping and Apify academies. t-tooling Issues with this label are in the ownership of the tooling team. t-docs Issues owned by technical writing team. labels Oct 10, 2024
@B4nan
Copy link
Member

B4nan commented Oct 11, 2024

I don't think docusaurus supports this, and it feels weird to mix those approaches. Either you get the ordering based on the names, or you use the explicit position in front matter.

https://docusaurus.io/docs/sidebar/autogenerated

@honzajavorek
Copy link
Collaborator Author

@B4nan If I understand you correctly, it should be possible to skip specifying sidebar_position if I'm 100 % sure that my files are sorted the correct way, because Docusaurus' default sorting is by filenames, alphabetically? That would be great!

@B4nan
Copy link
Member

B4nan commented Oct 11, 2024

Yes, but I am not sure how this works when you try to mix those two approaches, I would say it's one or the other.

@honzajavorek
Copy link
Collaborator Author

I wouldn't mix the approaches within one folder 🤔 I might give it a try and see if and how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-academy Issues related to Web Scraping and Apify academies. t-docs Issues owned by technical writing team. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

2 participants