From c62b1fd4010f21028caa62604c7815c2d63d4fe3 Mon Sep 17 00:00:00 2001 From: Xin Date: Sun, 14 Apr 2024 10:23:52 +0100 Subject: [PATCH] refactor: make sidebar footer work --- .../components/sidebar/collapsible-button.html | 5 +++++ .../partials/components/sidebar/footer.html | 12 ++++++++++++ .../partials/components/sidebar/item-link.html | 18 ++++++++++++++++++ layouts/partials/sidebar-ng.html | 1 + 4 files changed, 36 insertions(+) create mode 100644 layouts/partials/components/sidebar/collapsible-button.html create mode 100644 layouts/partials/components/sidebar/footer.html create mode 100644 layouts/partials/components/sidebar/item-link.html diff --git a/layouts/partials/components/sidebar/collapsible-button.html b/layouts/partials/components/sidebar/collapsible-button.html new file mode 100644 index 0000000..3ba74f3 --- /dev/null +++ b/layouts/partials/components/sidebar/collapsible-button.html @@ -0,0 +1,5 @@ + + + + + diff --git a/layouts/partials/components/sidebar/footer.html b/layouts/partials/components/sidebar/footer.html new file mode 100644 index 0000000..40871bd --- /dev/null +++ b/layouts/partials/components/sidebar/footer.html @@ -0,0 +1,12 @@ +{{- range site.Menus.sidebar }} + {{- $name := or (T .Identifier) .Name }} + {{- if eq .Params.type "separator" }} +
  • + {{ $name }} +
  • + {{- else }} +
  • + {{- partial "components/sidebar/item-link" (dict "active" false "title" $name "link" (.URL | relLangURL)) -}} +
  • + {{- end }} +{{- end -}} diff --git a/layouts/partials/components/sidebar/item-link.html b/layouts/partials/components/sidebar/item-link.html new file mode 100644 index 0000000..ea7396e --- /dev/null +++ b/layouts/partials/components/sidebar/item-link.html @@ -0,0 +1,18 @@ +{{- $external := strings.HasPrefix .link "http" -}} + + {{- .title -}} + {{- with .context }} + {{- if or .RegularPages .Sections }} + {{- partialCached "components/sidebar/collapsible-button" . }} + {{- end }} + {{ end -}} + diff --git a/layouts/partials/sidebar-ng.html b/layouts/partials/sidebar-ng.html index 0859002..8eeed1a 100644 --- a/layouts/partials/sidebar-ng.html +++ b/layouts/partials/sidebar-ng.html @@ -27,6 +27,7 @@ {{ warnf "The data file for the sidebar is still unstable. Please use caution when upgrading." }}
    {{ . | jsonify (dict "indent" "  ") }}
    {{ end }} + {{ partialCached "components/sidebar/footer" $context site.Home }}