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

Submenus cannot exist without main menu relation #43

Open
xaralis opened this issue Apr 16, 2019 · 0 comments
Open

Submenus cannot exist without main menu relation #43

xaralis opened this issue Apr 16, 2019 · 0 comments

Comments

@xaralis
Copy link
Collaborator

xaralis commented Apr 16, 2019

When item is not in the main menu, corresponding pages cannot have submenu.

This can be easily fixed by refactoring submenu.html like following:

{% for menu in site.data.menu.submenus %}
  {% if page.url contains menu.match %}
    <nav class="c-top-sub-nav">
      <div class="row">
        <div class="c-top-sub-nav-inner columns">
          <div class="c-top-sub-nav__header">
            <h2 class="c-top-sub-nav__heading">{{ menu.name }}</h2>
          </div>
          <div class="c-top-sub-nav-divider"></div>
          <ul class="c-top-sub-nav-items">
            {% for submenu in menu.items %}
            <li class="c-top-sub-nav__item {% if page.url contains submenu.match %}c-top-sub-nav__item--active{% endif %}">
              <a href="{{ submenu.link }}">{{ submenu.name }} </a>
            </li>
            {% endfor %}
          </ul>
        </div>
      </div>
    </nav>
  {% endif %}
{% endfor %}

Then, in menu.yml, you can configure submenus separately like this:

submenus:
  - name: Volby 2018
    match: komunalni-volby-2018
    items:
      - link: /komunalni-volby-2018/
        name: Radnice
        match: komunalni-volby-2018
      - link: /komunalni-volby-2018/mo-i/
        name: MO I
        match: mo-i
      - link: /komunalni-volby-2018/mo-ii/
        name: MO II
        match: mo-ii
      - link: /komunalni-volby-2018/mo-iv/
        name: MO IV
        match: mo-iv
      - link: /komunalni-volby-2018/mo-v/
        name: MO V
        match: mo-v
      - link: /komunalni-volby-2018/mapa-piratskych-planu/
        name: Mapa pirátských plánů
        match: mapa-piratskych-planu
      - link: /komunalni-volby-2018/povolebni-strategie/
        name: Povolební strategie
        match: povolebni-strategie
      - link: /komunalni-volby-2018/kampan-dary-prispevky/
        name: Financování kampaně
        match: kampan-dary-prispevky

Unfortunately, this is a breaking change. Do we want it in the main repository, too?

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