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>
| | |
| | | <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 . }} |
| | |
| | | {{ end }} |
| | | <a class="navigation-link {{ .Params.class }}" href="{{ index (apply (slice .URL) (.Params.urlFunc | default "relLangURL") ".") 0 }}"> |
| | | {{ .Name }} |
| | | </a> |
| | | </a> |
| | | </li> |
| | | {{ end }} |
| | | {{ end }} |