Add support for weight/order frontmatter field (or custom frontmatter fields) #3
Comments
@FezVrasta Hey! is this so you can group menu elements together, would a Happy to investigate though if you can provide a little more information? |
No it’s just to define their order in the menu. I can point you to the code I use right now in my website tomorrow. If you want to take a look it’s in the docs folder of github.com/popperjs/popper-core |
Hey @FezVrasta got ya! I've just released There's a new prop called This can be used as a reference array. If you exclude a If you're happy with this solution i'll close the issue. |
Thanks for the reply. With your addition I need to maintain a list, what I was loking for was a frontmatter prop I could use to automatically generate such list |
Hey @FezVrasta would you be able to provide a bit more detail, I’m afraid I’m not understanding what you’re looking to achieve |
Yes I’m sorry I’ll do that as soon I get home |
This is what I have now: Each pages defines its order index, and then the |
@FezVrasta have you got an online version of how that looks, I think i understand what you're trying to achieve but it might help if i could see where you're at or maybe a codePen would be an idea? |
This is the live website, the left nav menu is powered by that code. |
@FezVrasta ah got ya! so, the ability to group menu elements together by a parent menu is what you're after. I thought that was what you mean after i replied in the first comment. Yes that would be a good idea. Let me investigate! |
No, I'm sorry. I am grouping them manually using the folder structure already. I'm just looking for a frontmatter property I can use to define the index for each menu entry. Without it, Gatsby will sort the routes randomly, I want "Home" to be the first, and have a predefined order for all of the menu items. |
@FezVrasta ok, so i think we're getting somewhere. First up. I won't be adding any additional support for new The reason for this is because by putting properties in I am able to type this field and define a type for it if i Gatsby are working on a way to dynamically inject Until then we're stuck with making what we can out of the smallest amount of That's the background and perhaps i should have explained earlier why i was avoiding your My earlier update provides a way for you to pass a reference array to I don't think it will work with your grouped responses as it happens before All the const navigationOrder = ["Home", "Second Menu", "Third Menu" ]
.sort((a, b) =>
navigationOrder.indexOf(a.navigationLabel) -
navigationOrder.indexOf(b.navigationLabel)) I appreciate it means you have to manually type out an array of the order you'd like your navigation but this in my opinion is better than having to put a property into each and every file to determine an order. What do you think? |
@FezVrasta Check the readme. I've done quite a lot of work on this and there's now a nicer nested kinda object to create recursive menus with. it's called The Hopefully one of the new options will be able to help you get to where you need to be. Feel free to reach out again if you have any other questions. I'll be closing this issue now. Thanks! |
Thanks for the help, I'll check it out! |
I have a script that takes the routes generated by this plugin, and sorts them. I would like to use a
sort
orweight
frontmatter field to give hints to my script on how to sort the routes, but right now onlyslug
andnavigationLabel
are exposed.Would you mind adding support for
sort
orweight
, or maybe a way to define custom frontmatter fields to expose?The text was updated successfully, but these errors were encountered: