digitalcraftsman / hugo-agency-theme

Port of Startbootstrap's Agency theme to Hugo
http://themes.gohugo.io/theme/agency/
Apache License 2.0
160 stars 137 forks source link

Adding a submenu #102

Closed eurecomphil closed 6 years ago

eurecomphil commented 6 years ago

Thank you very much for your work. It is a very nice theme.

I was wondering if it was possible to use submenus ?

To be displayed when clicking on an item of "[[menu.prepend]]" Something like this example : https://i.stack.imgur.com/DW6nV.jpg

Thank you in advance !

lunk-liu commented 6 years ago

Add this to nav.html

        <li class="hidden-xs">
          <a href="#" class="dropdown-toggle visible-desktop" id="dropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          {{ .Site.Params.dropmenu.title}}
            <b class="caret"></b>
          </a>
          <div class="dropdown-menu dropdown-menu-left" aria-labelledby="dropdownMenuButton">
            {{ range .Site.Params.dropmenu.item }}
            <a class="dropdown-item" href="{{ .url | relURL }}">{{ .name }}</a>
            <br> {{ end }}
          </div>
        </li>

        {{ range .Site.Params.dropmenu.item }}
        <li class="visible-xs">
            <a href="{{ .url | relURL }}">{{ .name }}</a>
        </li>
        {{ end }}

and this to config.toml:

  [params.dropmenu]
    title = "This is a submenu button"

      [[params.dropmenu.item]]
        url = "/firstsub"
        name = "First sub menu"
        weight = 13
      [[params.dropmenu.item]]
        url = "/secondsub"
        name = "Second submenu"
        weight = 14
eurecomphil commented 6 years ago

Thanks a lot @lunk-liu ! I'll give a try. Have a nice day

stp-ip commented 6 years ago

Thanks @lunk-liu awesome for you to step up and help fix issues. Really appreciated.