Skip to content

Commit

Permalink
feat: add the nav_menus parameter for linking to external documentati…
Browse files Browse the repository at this point in the history
…ons (#573)
  • Loading branch information
razonyang authored Mar 7, 2024
1 parent cec33b3 commit bd5fe1d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
21 changes: 21 additions & 0 deletions layouts/partials/hb/modules/docs/nav-menus.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- $externalIcon := partial "icons/icon" (dict "vendor" "fas" "name" "arrow-up-right-from-square" "height" "1em" "width" "1em") }}
{{- $weighted := sort (where . "weight" "ne" nil) "weight" }}
{{- $unweighted := sort (where . "weight" "eq" nil) "name" }}
{{- range $weighted | append $unweighted }}
<li class="hb-docs-nav-links-span-all">
<a
class="hb-docs-nav-link d-flex align-items-center rounded"
target="_blank" href="{{ .url }}"
rel="external">
{{- with .icon }}
<span class="hb-docs-nav-link-icon d-flex me-2">
{{ partial "icons/icon" (merge (dict "height" "1em" "width" "1em") .) }}
</span>
{{- end }}
{{- .name -}}
<span class="hb-docs-nav-link-icon d-flex ms-auto">
{{ $externalIcon }}
</span>
</a>
</li>
{{- end }}
10 changes: 8 additions & 2 deletions layouts/partials/hb/modules/docs/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ <h5 class="offcanvas-title" id="hb-docs-nav-label">
<div class="offcanvas-body flex-column text-body-secondary">
<ul class="hb-docs-nav-links list-unstyled hb-module">
{{ template "walk-docs-tree" (dict "Tree" $tree "Page" .) }}
{{- with .FirstSection.Params.nav_menus }}
{{- partial "hb/modules/docs/nav-menus" . -}}
{{- end }}
</ul>
</div>
</div>
Expand All @@ -41,7 +44,7 @@ <h5 class="offcanvas-title" id="hb-docs-nav-label">
<a
class="d-flex flex-grow-1 align-items-center"
href="{{ $node.Page.RelPermalink }}">
{{- partial "hb/modules/docs/nav-menu" $node.Page -}}
{{- partial "hb/modules/docs/nav-link" $node.Page -}}
</a>
{{ if .Children }}
<button
Expand All @@ -66,6 +69,9 @@ <h5 class="offcanvas-title" id="hb-docs-nav-label">
class="collapse list-unstyled fw-normal small ms-2{{ cond $active ` show` `` }}"
id="{{ $collapseId }}">
{{- template "walk-docs-tree" (dict "Tree" . "Page" $page) }}
{{- with $node.Page.Params.nav_menus }}
{{- partial "hb/modules/docs/nav-menus" . -}}
{{- end }}
</ul>
{{- end }}
</li>
Expand All @@ -78,7 +84,7 @@ <h5 class="offcanvas-title" id="hb-docs-nav-label">
{{ else }}
href="{{ .Page.RelPermalink }}"
{{ end }}>
{{- partial "hb/modules/docs/nav-menu" $node.Page -}}
{{- partial "hb/modules/docs/nav-link" $node.Page -}}
</a>
</li>
{{- end }}
Expand Down

0 comments on commit bd5fe1d

Please sign in to comment.