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

Japanese in sidebar menu #14

Open
RickCogley opened this issue Oct 10, 2024 · 5 comments
Open

Japanese in sidebar menu #14

RickCogley opened this issue Oct 10, 2024 · 5 comments

Comments

@RickCogley
Copy link
Contributor

hello - this a question/request and what appears to be a bug.

I know that I can get Japanese kanji names into the sidebar menu by setting the url param in each page, making the first part of the url kanji. For example:

  • url: /Bousai/esolia-bousai-links/ yields "Bousai" in the menu.
  • url: /防災/esolia-bousai-links/ yields "防災" in the menu.

In a Japanese context having 防災 makes more sense in the menu, but sometimes having kanji in an URL makes problems. The kanji get converted to entities sometimes, and this leads to too-long urls in some cases.

So my question is, is there a way to have menu.js pick up a kanji from somewhere to use in the sidebar display?

Secondly, what I think is a bug. When I set the url to kanji, like url: /防災/esolia-bousai-links/, the breadcrumbs break. Please see the two screenshots showing where breadcrumbs are working, and not working when the url contains kanji.

This has a "smell" of something needing to be sent to a filter to sanitize before doing the logic in breadcrumbs.vto.

Screenshot 2024-10-11 at 8 41 21 Screenshot 2024-10-11 at 8 41 59
@oscarotero
Copy link
Member

The sidebar shows the page title, or the url slug as a fallback. So you can have a Japanese title with english url and it will show the Japanese text in the menu. Note that for folders, this requires a index page to take the title from. You can create a index page by creating a index.md file in the folder or a markdown file with the same name as the folder. For example:

my-folder/index.md

is equivalent to

my-folder.md

And about the breadcrumb, I just checked it and yes, it's a bug in the Lume plugin.
I just fixed and will be available in the next version of Lume.
To use it now, upgrade Lume to the latest development version with deno task lume upgrade --dev.

@RickCogley
Copy link
Contributor Author

Appreciate it, that's an elegant solution to the problem. Thanks for the breadcrumb fix too!

@RickCogley
Copy link
Contributor Author

Just reopening to make a comment. So I got this up and running and see how having the index.md gives you the capability of setting the "folder" name. From a UX perspective, if you just want to use this feature for putting a Japanese name in place of an English URL, introducing the ability to click the menu title is perhaps confusing (if you have no intent to make index.md an actual index page, it just shows "page is empty"). If the user knows they just have to click the caret to get at the child pages, a consistent UX is better. Can there be a way to suppress link creation in the menu, for those index pages, if you don't need to show that empty page?

Secondly regarding order, I added indexes just for two of four folders, because I don't need it for "M365" or "PROdb" which are just the way we write those in Japanese as well. I was able to control order by adding order=100 etc to the pages, but it would be good if I could control the order of the index-less folders, say by adding order to _data.yml? With the current setup, I have order set on the Japanese folders with index.md's, but not on the index-less English ones. So the English ones just float to the bottom.

https://github.com/esolia/help.esolia.pro

Screenshot 2024-10-13 at 16 00 39 Screenshot 2024-10-13 at 16 02 41

@RickCogley RickCogley reopened this Oct 13, 2024
@oscarotero
Copy link
Member

Can there be a way to suppress link creation in the menu, for those index pages, if you don't need to show that empty page?

Not currently. And I'm not sure if it's easy to do that. Nav plugin is based on the URLs of the pages and the good practice of providing a page for every folder of a url. For example the url /company/people/ceo/ should show something if the user removes the last directory (/company/people/) and again (/company/). This makes the url more semantic and understandable.

it would be good if I could control the order of the index-less folders

As said, the plugin only use page urls to build the tree. The reason is: as you know, Lume allows to customize the url of a page, so a page stored in /my-pages/about-me.md can generate a page with the url /cv/personal-info/ (or whatever you want). This page in the navigation tree is under the "cv" folder (even if this folder doesn't exist really in src). This is why the plugin only uses the pages to read data, because the folders can exist or not. Or even if the folder exist, there may be pages outside this folder with a custom url making them to appear in the folder in the navigation tree.

That being said, I know that this strictness doesn't fit well for all cases. I'll think of a elegant way to configure the order.

@RickCogley
Copy link
Contributor Author

well understood, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants