From d15383ba899cafaad60ded8338507ee0e00ebf5b Mon Sep 17 00:00:00 2001 From: ROOMrepair Date: Thu, 31 Oct 2024 17:54:32 +0800 Subject: [PATCH] fix: try to remove contents that do not match version in hover menu Signed-off-by: ROOMrepair --- content/en/docs/v4.1/_index.adoc | 1 + content/zh/docs/v4.1/_index.adoc | 1 + layouts/docs/list.html | 2 +- layouts/docs/second.html | 5 ++- layouts/docs/single.html | 5 ++- layouts/partials/section.html | 49 +++++++++--------------------- layouts/partials/section_item.html | 32 +++++++++++++++++++ 7 files changed, 58 insertions(+), 37 deletions(-) create mode 100644 layouts/partials/section_item.html diff --git a/content/en/docs/v4.1/_index.adoc b/content/en/docs/v4.1/_index.adoc index 4210f82ef..aeddf45f8 100644 --- a/content/en/docs/v4.1/_index.adoc +++ b/content/en/docs/v4.1/_index.adoc @@ -8,6 +8,7 @@ section1: title: KubeSphere Documentation content: Learn how to build and manage cloud-native applications using KubeSphere Container Platform. Get documentation, example code, tutorials, and more. image: /images/docs/common/banner.png + version: v4.1 sectionLink: docs: diff --git a/content/zh/docs/v4.1/_index.adoc b/content/zh/docs/v4.1/_index.adoc index 2d815e353..0839a618f 100644 --- a/content/zh/docs/v4.1/_index.adoc +++ b/content/zh/docs/v4.1/_index.adoc @@ -8,6 +8,7 @@ section1: title: KubeSphere content: 了解如何通过 KubeSphere 构建并管理云原生应用程序。获取文档、示例代码与教程等信息。 image: /images/docs/common/banner.png + version: v4.1 sectionLink: docs: diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 65e89a98c..3f14d5661 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -50,7 +50,7 @@
- {{ partial "section" . }} + {{ partial "section" (dict "context" .) }}
diff --git a/layouts/docs/second.html b/layouts/docs/second.html index e5b3f1d84..0ca39d01a 100644 --- a/layouts/docs/second.html +++ b/layouts/docs/second.html @@ -40,10 +40,13 @@ height="0" width="0" style="display:none;visibility:hidden"> + {{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}} + +
{{ with (.GetPage "/docs") }}
- {{ partial "section" . }} + {{ partial "section" (dict "context" . "ver" $version) }}
{{ end }}
diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 4638628bf..e974bcdf6 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -41,10 +41,13 @@ + {{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}} + +
{{ with (.GetPage "/docs") }}
- {{ partial "section" . }} + {{ partial "section" (dict "context" . "ver" $version) }}
{{ end }}
diff --git a/layouts/partials/section.html b/layouts/partials/section.html index e8a5cb865..b7b052001 100644 --- a/layouts/partials/section.html +++ b/layouts/partials/section.html @@ -1,41 +1,22 @@ -{{ $sections := .Sections.ByWeight }} \ No newline at end of file diff --git a/layouts/partials/section_item.html b/layouts/partials/section_item.html new file mode 100644 index 000000000..df41e333a --- /dev/null +++ b/layouts/partials/section_item.html @@ -0,0 +1,32 @@ +
  • +

    + {{ .LinkTitle }} + {{ .LinkTitle }} +

    + {{ $page_list := (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }} + {{ $length := len $page_list}} +
      + {{ if gt $length 6 }} + {{ range first 5 $page_list }} +
    • + {{ if .IsPage }} + {{ .LinkTitle }} + {{ else }} + {{ partial "firstPageInSection" (dict "section" . "firstSection" .) }} + {{ end }} +
    • + {{ end }} +
    • {{ i18n "Learn More" }}...
    • + {{ else }} + {{ range first 6 $page_list }} +
    • + {{ if .IsPage }} + {{ .LinkTitle }} + {{ else }} + {{ partial "firstPageInSection" (dict "section" . "firstSection" .) }} + {{ end }} +
    • + {{ end }} + {{ end }} +
    +
  • \ No newline at end of file