Skip to content

Commit 9f186bd

Browse files
authored
refactor!: add about in reorderNavItems (#371)
1 parent 0f8bdcd commit 9f186bd

7 files changed

+34
-33
lines changed

docs/pages/custom-nav-items.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Dream will find them and append them to the navbar by default.
2525
You can also reorder custom items with the default items by setting the `reorderNavItems` parameter in your `hugo.toml`:
2626

2727
```toml
28-
reorderNavItems = ["github", "search", "rss", "posts", "categories", "tags", "series"]
28+
reorderNavItems = ["github", "about", "search", "rss", "posts", "categories", "tags", "series"]
2929
```
3030

3131
The same goes for `collapseNavItems`, you can also collapse custom items to a dropdown menu:

docs/pages/params-configurations.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Reorder the navigation items.
249249
This parameter is **an array of strings**, the default value is:
250250

251251
```toml
252-
reorderNavItems = ["search", "rss", "posts", "categories", "tags"]
252+
reorderNavItems = ["about", "search", "rss", "posts", "categories", "tags"]
253253
```
254254

255255
<Callout type="info">
@@ -260,10 +260,11 @@ reorderNavItems = ["search", "rss", "posts", "categories", "tags"]
260260
This parameter also allows you to remove the default navigation items.
261261
For example, if you don't want to show the `rss` item, you can set the value as:
262262

263-
`reorderNavItems = ["search", "posts", "categories", "tags"]`
263+
`reorderNavItems = ["about", "search", "posts", "categories", "tags"]`
264+
264265
</Callout>
265266

266-
For reordering custom navigation items, see [Custom Navbar Items](custom-nav-items.md).
267+
For reordering custom navigation items, see [Custom Navbar Items](custom-nav-items.mdx).
267268

268269
### collapseNavItems
269270

hugo.example.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ siteStartYear = 2016
4949

5050
# options
5151
# stickyNav = true
52-
# reorderNavItems = ["search", "rss", "posts", "categories", "tags"]
52+
# reorderNavItems = ["about", "search", "rss", "posts", "categories", "tags"]
5353
# collapseNavItems = ["posts", "categories", "tags"]
5454
# noDefaultSummaryCover = true
5555
# showTableOfContents = true

layouts/partials/nav.html

+1-14
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,7 @@
4141
</ul>
4242
</div>
4343
<section class="hidden sm:flex sm:items-center sm:gap-2 md:gap-4">
44-
{{ with site.GetPage "/about" }}
45-
{{ $aboutPages := .Resources.ByType "page" }}
46-
{{ if gt (len $aboutPages) 0 }}
47-
<div role="link" tabindex="0"
48-
class="text-sm font-semibold cursor-pointer hover:underline"
49-
@click="flip = !flip"
50-
title="{{ T "about" }}"
51-
>
52-
{{- T "about" -}}
53-
</div>
54-
{{ end }}
55-
{{ end }}
56-
57-
{{ $navItems := slice "search" "rss" "posts" "categories" "tags" }}
44+
{{ $navItems := slice "about" "search" "rss" "posts" "categories" "tags" }}
5845
{{ if site.Params.reorderNavItems }}
5946
{{ $navItems = site.Params.reorderNavItems }}
6047
{{ end }}

layouts/partials/navMobileMenu.html

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
{{ with site.GetPage "/about" }}
2-
{{ $aboutPages := .Resources.ByType "page" }}
3-
{{ if gt (len $aboutPages) 0 }}
4-
<li>
5-
<div role="link" tabindex="0" class="inline-flex items-center p-2 cursor-pointer" @click="flip = !flip" title="{{ T "about" }}">
6-
<ion-icon name="information-circle"></ion-icon>
7-
{{- T "about" -}}
8-
</div>
9-
</li>
10-
{{ end }}
11-
{{ end }}
12-
131
{{ $navItems := slice "search" "rss" "posts" "categories" "tags" }}
142
{{ if site.Params.reorderNavItems }}
153
{{ $navItems = site.Params.reorderNavItems }}

layouts/partials/renderMobileNavItem.html

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
{{ if and (eq . "search") (gt (len (where site.Pages "Type" "search")) 0) }}
1+
{{ if (eq . "about") }}
2+
3+
{{ with site.GetPage "/about" }}
4+
{{ $aboutPages := .Resources.ByType "page" }}
5+
{{ if gt (len $aboutPages) 0 }}
6+
<li>
7+
<div role="link" tabindex="0" class="inline-flex items-center p-2 cursor-pointer" @click="flip = !flip" title="{{ T "about" }}">
8+
<ion-icon name="information-circle"></ion-icon>
9+
{{- T "about" -}}
10+
</div>
11+
</li>
12+
{{ end }}
13+
{{ end }}
14+
15+
{{ else if and (eq . "search") (gt (len (where site.Pages "Type" "search")) 0) }}
216
<li>
317
<a class="group inline-flex items-center p-2 cursor-pointer" href="{{ "search" | relLangURL }}" title="{{ T "search" }}">
418
<ion-icon name="search"></ion-icon>

layouts/partials/renderNavItem.html

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
{{ if and (eq . "search") (gt (len (where site.Pages "Type" "search")) 0) }}
1+
{{ if and (eq . "about") }}
2+
3+
{{ with site.GetPage "/about" }}
4+
{{ $aboutPages := .Resources.ByType "page" }}
5+
{{ if gt (len $aboutPages) 0 }}
6+
<div role="link" tabindex="0" class="text-sm font-semibold cursor-pointer hover:underline" @click="flip = !flip" title="{{ T "about" }}">
7+
{{- T "about" -}}
8+
</div>
9+
{{ end }}
10+
{{ end }}
11+
12+
{{ else if and (eq . "search") (gt (len (where site.Pages "Type" "search")) 0) }}
213
<a class="group inline-flex items-center p-2 rounded-full cursor-pointer hover:bg-primary" href="{{ "search" | relLangURL }}" title="{{ T "search" }}">
314
<ion-icon class="group-hover:text-primary-content" name="search"></ion-icon>
415
</a>

0 commit comments

Comments
 (0)