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

Error when no menu items are set in config file #165

Closed
mattstratton opened this issue Mar 7, 2018 · 6 comments
Closed

Error when no menu items are set in config file #165

mattstratton opened this issue Mar 7, 2018 · 6 comments
Labels

Comments

@mattstratton
Copy link
Owner

Currently, if no menu is set, the theme will error out. Should add a check to ensure there are menu items before trying to display them.

@thunderrabbit
Copy link

I'd like to have a crack at this. Where in the code does this check need to happen?

I am asking because I want to add different menu items, so I will be happy to mess with menu stuff for a bit.

@mattstratton
Copy link
Owner Author

mattstratton commented Dec 7, 2020

The code to fix is here: https://github.com/mattstratton/castanet/blob/master/layouts/partials/header.html#L11

Basically, we need to wrap the whole menu part with a query that does a range of .Site.Menus.main and if the count is <1, then it shouldn't execute any of the menu code I think.

GitHub
A podcast-oriented theme for Hugo. Contribute to mattstratton/castanet development by creating an account on GitHub.

@chrisreddington
Copy link
Contributor

@mattstratton - Think it would be something like this..

{{ if ge (len .Site.Menus.main) 1 }}
// Display the menu
{{ end }}

Happy to include it in one of my PRs and test, if useful?

@chrisreddington
Copy link
Contributor

Also, I guess this is a bug rather than enhancement :)

@mattstratton mattstratton changed the title Check for existence of menu items prior to displaying menu in header Error when no menu items are set in config file Dec 13, 2020
@mattstratton
Copy link
Owner Author

I think this looks like the right test. I would put it in as a separate PR though rather than pushing it with another one, just to keep it cleaner.

@mattstratton
Copy link
Owner Author

Fixed in #371

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

No branches or pull requests

3 participants