minimal-mistakes icon indicating copy to clipboard operation
minimal-mistakes copied to clipboard

Multiple Sidebar Nav Lists

Open tsmanner opened this issue 4 years ago • 5 comments

This is an enhancement or feature.

Summary

This implements a small change to the nav_bar include that iterates over elements in the page.sidebar.nav variable, creating nav links for each of them. Existing behavior is unchanged, the new behavior allows the following YAML as well.

sidebar:
  nav:
    - main
    - docs

Context

This is not related to any issues. It is a small change to the include file that allows for more configuration reuse for common navigation elements.

Let me know what you think. I have one thought already which is that I'm not sure if the nav_bar loop should be inside or outside the <ul class="nav__items"> tag, or possibly even outside the <nav class="nav__list"> tag with a sidebar.nav.[nav].title key or something like that. Doing it that way seemed to be introducing a lot more complexity without gaining much usefulness, so I went for the simplest solution here.

tsmanner avatar Feb 24 '21 01:02 tsmanner

Have you tested this? I'm afraid it breaks existing setup.

iBug avatar Feb 24 '21 14:02 iBug

Huh, I tested it, but with something very simple, I'll take another look today with some more complexity. I'm okay with closing this in the meantime if you'd like to unclutter the list a bit, I can always reopen it later.

tsmanner avatar Feb 24 '21 14:02 tsmanner

Looks OK to me.

The point I missed was that looping over a string in Liquid is like looping over an array with just that string.

iBug avatar Feb 24 '21 14:02 iBug

Ah, got it. It's a pretty handy feature. I did some more testing on a larger page and it seems to be holding up there.

tsmanner avatar Feb 24 '21 14:02 tsmanner

This pull request has been automatically marked as stale because it has not had recent activity.

This pull request will automatically be closed in 7 days if no further activity occurs. Thank you for all your contributions.

github-actions[bot] avatar May 13 '21 02:05 github-actions[bot]