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

Best practices guide for editing Hugo menus in CloudCannon #72

Open
rycoll opened this issue May 12, 2023 · 0 comments
Open

Best practices guide for editing Hugo menus in CloudCannon #72

rycoll opened this issue May 12, 2023 · 0 comments

Comments

@rycoll
Copy link
Contributor

rycoll commented May 12, 2023

This will need to wait for an upcoming improvements on object inputs 👀 but it would be good to have a guide on how to best manage Hugo menus in CloudCannon.

I'll moved over some starter content from Notion below 👇


We can use our Input Configuration and Structures.

After setting some configuration for menus in your Hugo config file, it then depends how you want to choose menus in each file.

Simple Menu

Here’s an example for being able to choose what menus a file appears in:

/content/about.md

---
menu:
  - footer
  - main
---

Then the _inputs configuration:

/cloudcannon.config.yml

_inputs:
  menu:
    type: multiselect
    options:
      values:
        main: Heading menu
        footer: Footer
        aside: Right sidebar

That gives you this input:

Untitled

Advanced menu:

This is the one with weight and parent keys:

/content/about.md

---
menu:
  main:
    weight: 4
  footer:
    weight: 4
    parent: main
---

Once we have released support for adding keys to an object, you'll be able to configure something more flexible using the allowed_keys config:

/cloudcannon.config.yml

_inputs:
  menu:
    type: object
    options:
      allowed_keys:
        - main
        - footer
        - aside
  menu.*:
    type: object
      options:
        structures:
          values:
            - label: Menu Item
              value:
                weight:
                parent:
  weight:
    type: number
  parent:
    type: select
    options:
      values:
        main: Heading menu
        footer: Footer
        aside: Right sidebar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant