mirror of https://github.com/luizdepra/hugo-coder.git

Jens Rantil
22 hours ago 75b8ebcff506656ce6b53f79ae406032777f2aa4
feat: sort the menu items by weight (#1017)

### Prerequisites

Put an `x` into the box(es) that apply:

- [ ] This pull request fixes a bug.
- [ ] This pull request adds a feature.
- [x] This pull request introduces breaking change.

### Description

Sorting menu items is done implicitly by Hugo. Sorting against a generic
struct does not feel like canonical Hugo.

This change is a backwards-incompatible change that risk reordering menu
items if someone has not set proper `weight` attribute on their menu
items defined in `config.toml`.

### Issues Resolved

N/A. I'll let this PR speak for itself.

### Checklist

Put an `x` into the box(es) that apply:

#### General

- [x] Describe what changes are being made
- [x] Explain why and how the changes were necessary and implemented
respectively
- [x] Reference issue with `#<ISSUE_NO>` if applicable

#### Resources

- [x] If you have changed any SCSS code, run `make release` to
regenerate all CSS files

#### Contributors

- [x] Add yourself to `CONTRIBUTORS.md` if you aren't on it already

Co-authored-by: Luiz F. A. de PrĂ¡ <luizdepra@users.noreply.github.com>
1 files modified
4 ■■■■■ changed files
layouts/_partials/header.html 4 ●●●●● patch | view | raw | blame | history
layouts/_partials/header.html
@@ -13,7 +13,7 @@
      <ul class="navigation-list">
        {{ $currentPage := . }}
        {{ with .Site.Menus.main}}
          {{ range sort . }}
          {{ range . }}
            {{ if $currentPage.IsMenuCurrent .Menu . }}
            <li class="navigation-item active" aria-current="page">
            {{ else if $currentPage.HasMenuCurrent .Menu . }}
@@ -23,7 +23,7 @@
            {{ end }}
              <a class="navigation-link {{ .Params.class }}" href="{{ index (apply (slice .URL) (.Params.urlFunc | default "relLangURL") ".") 0 }}">
                {{ .Name }}
          </a>
                </a>
            </li>
          {{ end }}
        {{ end }}