-
Notifications
You must be signed in to change notification settings - Fork 314
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
TOC-Tree sorts alphabettically instead of how the site sorts it #736
Comments
The Toc-Tree shortcode is not intended to be used together with the sidebar menu. It is using the Hugo section object and creates a Toc in an alphabetic order. Therefor, any manual menu order created with the bundle menu cant be reflected by this shortcode. But maybe I misunderstand your issue. |
Oh I see. Configuration:
- Default settings
- Cli Options
- Environment variables And then on the ---
title: Configuration
---
Some preamble about configuration stuff, blabla
Table of Contents:
{{<toc-tree>}} where the table of contents would then be ordered the same way as the sidebar. I'm honestly still a hugo noob, and also haven't looked into the codebase here at all. So I'm not sure whether it'd be worth the effort to provide a parameter to the shortcode to provide different sortings. |
The problem is, I don't see a way how to solve it. The bundle menu is a fully customizable menu with a manual order. This manual order can't be reflected by the toc-tree shortcode.
How should such a parameter look like if the ordering is fully controlled by the user? |
Is it not possible for the shortcode to retrieve/read the tree at data/main.yaml?
I was thinking that, if the shortcode is unable to gather the manual order, that one might want to specify another parameter, other than the title, to order things for. For example the Using weight to sort instead of the title it could maybe help for File-tree menus though. |
Sure it is but, we would have to read and loop over this YAML file every time when the toc-tree shortcode is used. Doing it once to build the main menu is one thing, but doing it quiet often for a shortcode doesn't really scale and IMO too complex for this use-case.
Definitely! Stumbled over it yesterday as well, we have this feature already for the filetree menu, and at least this logic should be added to the filetree menu as well. |
Alternative ramblings: is it possible for something very early in the building-site process to read the main.yaml, then loop over all its pages, and manually give it a weight parameter? |
Where does this value come from? However, AFAIK there is no way to manipulate Hugos Page objects to dynamically add page parameters. |
I'd just use a running counter from 0 to however many pages there are
Would this not work? |
If I have a category like this:
then using
toc-tree
will display that alphabettically instead:The text was updated successfully, but these errors were encountered: