fix: try to remove contents that do not match version in hover menu

Signed-off-by: ROOMrepair <twekjz@gmail.com>
This commit is contained in:
ROOMrepair 2024-10-31 17:54:32 +08:00
parent 53b9c9a711
commit d15383ba89
7 changed files with 58 additions and 37 deletions

View File

@ -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:

View File

@ -8,6 +8,7 @@ section1:
title: KubeSphere
content: 了解如何通过 KubeSphere 构建并管理云原生应用程序。获取文档、示例代码与教程等信息。
image: /images/docs/common/banner.png
version: v4.1
sectionLink:
docs:

View File

@ -50,7 +50,7 @@
<section class="section-2">
<div class="common-layout">
{{ partial "section" . }}
{{ partial "section" (dict "context" .) }}
</div>
</section>

View File

@ -40,10 +40,13 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
</div>
</section>
{{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}}
<!-- {{ $doc_version := printf "/docs/%s" $version }} -->
<section class="section-menu">
{{ with (.GetPage "/docs") }}
<div class="common-layout">
{{ partial "section" . }}
{{ partial "section" (dict "context" . "ver" $version) }}
</div>
{{ end }}
</section>

View File

@ -41,10 +41,13 @@
</div>
</section>
{{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}}
<!-- {{ $doc_version := printf "/docs/%s" $version }} -->
<section class="section-menu">
{{ with (.GetPage "/docs") }}
<div class="common-layout">
{{ partial "section" . }}
{{ partial "section" (dict "context" . "ver" $version) }}
</div>
{{ end }}
</section>

View File

@ -1,41 +1,22 @@
{{ $sections := .Sections.ByWeight }}
<ul class="common-flex-layout">
{{ range $sections }}
<li>
<p>
<span><img src="{{ .Params.icon }}" alt="{{ .LinkTitle }}"></span>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</p>
{{ $page_list := (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ $length := len $page_list}}
<ul>
{{ if .ver }}
{{ $sections := where .context.Sections ".Params.section1.version" "==" .ver }}
{{ if gt $length 6 }}
{{ range first 5 $page_list }}
<li>
{{ if .IsPage }}
<a href="{{ .RelPermalink }}" title="{{ .LinkTitle }}">{{ .LinkTitle }}</a>
{{ else }}
{{ partial "firstPageInSection" (dict "section" . "firstSection" .) }}
{{ end }}
</li>
{{ end }}
<li><a href="{{ .RelPermalink }}">{{ i18n "Learn More" }}...</a></li>
{{ else }}
{{ range first 6 $page_list }}
<li>
{{ if .IsPage }}
<a href="{{ .RelPermalink }}" title="{{ .LinkTitle }}">{{ .LinkTitle }}</a>
{{ else }}
{{ partial "firstPageInSection" (dict "section" . "firstSection" .) }}
{{ end }}
</li>
{{ end }}
{{ end }}
</ul>
</li>
{{ range $sections }}
{{ partial "section_item" . }}
{{ end }}
{{ range $sections }}
<li style="height: 0; margin: 0; padding: 0;"></li>
{{ end }}
<!-- render all -->
{{ else }}
{{ $sections := .context.Sections.ByWeight }}
{{ range $sections }}
{{ partial "section_item" . }}
{{ end }}
{{ range $sections }}
<li style="height: 0; margin: 0; padding: 0;"></li>
{{ end }}
{{ end }}
</ul>

View File

@ -0,0 +1,32 @@
<li>
<p>
<span><img src="{{ .Params.icon }}" alt="{{ .LinkTitle }}"></span>
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
</p>
{{ $page_list := (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ $length := len $page_list}}
<ul>
{{ if gt $length 6 }}
{{ range first 5 $page_list }}
<li>
{{ if .IsPage }}
<a href="{{ .RelPermalink }}" title="{{ .LinkTitle }}">{{ .LinkTitle }}</a>
{{ else }}
{{ partial "firstPageInSection" (dict "section" . "firstSection" .) }}
{{ end }}
</li>
{{ end }}
<li><a href="{{ .RelPermalink }}">{{ i18n "Learn More" }}...</a></li>
{{ else }}
{{ range first 6 $page_list }}
<li>
{{ if .IsPage }}
<a href="{{ .RelPermalink }}" title="{{ .LinkTitle }}">{{ .LinkTitle }}</a>
{{ else }}
{{ partial "firstPageInSection" (dict "section" . "firstSection" .) }}
{{ end }}
</li>
{{ end }}
{{ end }}
</ul>
</li>