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

[Feature Request] Specify which folders in ToC are expanded by default #576

Open
michjnich opened this issue Apr 4, 2022 · 4 comments
Open
Labels
enhancement New feature or request feature

Comments

@michjnich
Copy link

Allow ToC to expand sections by default

Say I have a posts structure as follows:

Posts
-- Tech
-- -- 2022
-- -- 2021
-- -- 2020
-- Personal
-- -- 2022

At the moment, when I go into posts I will see Tech and Personal at the top level. I would also like to see the expanded view of Tech though, and possibly even the expanded view of the most recent year (2022).

Describe alternatives you've considered

The solution I was considering was to add a parameter to the _index.md file for these folders to set expand. The default would be false (as is) and would only change if explicitly set.

So, eg.

---
title: Technology
menu:
  sidebar:
    name: Tech
    identifier: tech
    expand: true
    weight: 1000
---

If this is set then the section is expanded by default when the page is created.

Additional context

N/A

@hossainemruz
Copy link
Member

The menu structure does not accept any custom parameter. So, we can't have the expand field there.

@michjnich
Copy link
Author

That's a shame. Not sure where else something like that could go?

Perhaps a single expandedPosts could be set in config,toml that could be either a menu or a post tag, and everything down to that would expand automatically? That would get most of the way there, even if it's not quite as flexible as being able to set true/false individually.

@hossainemruz
Copy link
Member

Yes. That's probably will be the way to go.

@hossainemruz
Copy link
Member

It seems that Menu can take a map in Params field. We should be able to use that to add expand logic.

Ref: https://github.com/gohugoio/hugo/blob/b80853de90b10171155b8f3fde47d64ec7bfa0dd/navigation/menu.go#L48

@hossainemruz hossainemruz added feature enhancement New feature or request and removed feature labels May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
No open projects
Status: Todo
Development

No branches or pull requests

2 participants