From 701c81afce8435c0876dd80e00f22750736403b4 Mon Sep 17 00:00:00 2001 From: ROOMrepair Date: Wed, 30 Oct 2024 18:04:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E9=A1=B5=E8=B7=B3=E8=BD=AC=E6=B7=B7=E4=B9=B1?= =?UTF-8?q?=E5=92=8C=20hover=20=E6=96=87=E6=A1=A3=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 593 ++++++++++++----------- layouts/docs/single.html | 52 +- layouts/partials/findFirstInSection.html | 9 + layouts/partials/findLastInSection.html | 23 + layouts/partials/page_navigate.html | 195 ++++++++ layouts/partials/pagination.html | 45 ++ layouts/partials/section.html | 50 +- layouts/partials/section_item.html | 33 ++ layouts/partials/tree.html | 43 +- 12 files changed, 681 insertions(+), 366 deletions(-) create mode 100644 layouts/partials/findFirstInSection.html create mode 100644 layouts/partials/findLastInSection.html create mode 100644 layouts/partials/page_navigate.html create mode 100644 layouts/partials/pagination.html 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..b4914e049 100644 --- a/layouts/docs/second.html +++ b/layouts/docs/second.html @@ -1,332 +1,341 @@ + {{- partial "head.html" . -}} -{{ if .Site.Params.addGoogleTag }} - - - -{{ end }} -{{- partial "header.html" . -}} -
-
-
- {{ partial "breadcrumb.html" . }} - -
- {{ $sections := .FirstSection.Sections.ByWeight }} - {{ $secondSection := .FirstSection }} - {{ $page := . }} - {{ range $sections }} + {{ if .Site.Params.addGoogleTag }} + + + + {{ end }} + {{- partial "header.html" . -}} +
+
+
+ {{ partial "breadcrumb.html" . }} + +
+ {{ $sections := .FirstSection.Sections.ByWeight }} + {{ $secondSection := .FirstSection }} + {{ $page := . }} + {{ range $sections }} {{ if $page.IsDescendant . }} - {{ $secondSection = . }} + {{ $secondSection = . }} {{ end }} - {{ end }} -

{{ $secondSection.LinkTitle }}

- + +
+ {{ partial "searchInput" . }}
- -
- {{ partial "searchInput" . }} +
+ + {{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}} + + +
+ {{ with (.GetPage "/docs" ) }} +
+ {{ partial "section" (dict "context" . "ver" $version) }}
-
-
- -
- {{ with (.GetPage "/docs") }} -
- {{ partial "section" . }} -
- {{ end }} -
- -
-
-
-
- {{ partial "tree.html" . }} - -
-
-
-
-
-
-
-
-
-
- {{ i18n "Last updated" }}: - - -
    -
    -
    -
    - +
    +
    +
    +
    +
    +
    +
    + - - - {{ define "content" }} - {{ if .context.IsSection }} - {{ .context.LinkTitle }} - {{ else }} - {{ .context.LinkTitle }} - {{ end }} -

    {{ .context.Description }}

    - {{ $count := add .count 1 }} - {{ if .context.IsSection }} - {{ range (union (where .context.Pages ".context.Params._build.render" "!=" false) .context.Sections).ByWeight }} + {{ define "content" }} + {{ if .context.IsSection }} + {{ .context.LinkTitle }} + {{ else }} + {{ .context.LinkTitle }} + {{ end }} +

    {{ .context.Description }}

    + {{ $count := add .count 1 }} + {{ if .context.IsSection }} + {{ range (union (where .context.Pages ".context.Params._build.render" "!=" false) + .context.Sections).ByWeight }} {{ template "content" (dict "context" . "count" $count) }} - {{ end }} - {{ else}} - {{ end }} - {{ end }} - -
    -
    -

    {{ .Title }}

    - {{ .Content }} - {{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }} - {{ template "content" (dict "context" . "count" 2) }} - {{ end }} + {{ end }} + {{ else}} + {{ end }} + {{ end }} + +
    +
    +

    {{ .Title }}

    + {{ .Content }} + {{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }} + {{ template "content" (dict "context" . "count" 2) }} + {{ end }} +
    + + + + {{ if .IsPage }} + + {{ partial "pagination" . }} + + + {{ end }} + +
    {{ if .IsPage }} - -
    - {{ with .Next }} - - - {{ i18n - {{ i18n "Previous" }} - : {{.LinkTitle}} - - - {{ end }} - {{ with .Prev }} - - - - {{ end }} +
    +
    +
    + {{ i18n "What’s on this Page" }} +
    +
    + {{ .TableOfContents }} +
    +
    {{ end }} -
    - {{ if .IsPage }} -
    -
    -
    - {{ i18n "What’s on this Page" }} -
    -
    - {{ .TableOfContents }} -
    -
    -
    - {{ end }} -
    -
    - {{ $aside := resources.Get "js/aside.js" }} - {{ $asideJS := $aside | resources.Fingerprint "sha512" }} - - - {{ $tab := resources.Get "js/markdown-tab.js" }} - {{ $tabJS := $tab | resources.Fingerprint "sha512" }} - - - + + {{ $tab := resources.Get "js/markdown-tab.js" }} + {{ $tabJS := $tab | resources.Fingerprint "sha512" }} + + + -
    + var renderLatestTime = function (time) { + $('.update-time').html(time) + } -
    -
    -
    - - {{ "/static/images/footer/wechat.svg" | readFile | safeHTML }} -
    -

    Follow the official account

    - -
    -
    - - - - - - - + var bindClickMenu = function () { + var sectionMenu = $(".section-menu") + $('.section-control').on('mouseenter', function (e) { + if (sectionMenu.is(":hidden")) { + sectionMenu.show(); + } + }) + + sectionMenu.on('mouseleave', function () { + sectionMenu.hide(); + }) + + $(document).on("click", function () { + sectionMenu.hide() + }); + + sectionMenu.on("click", function (e) { + e.stopPropagation(); + }) + } + + var bindClickSecondMenu = function () { + var sectionMenu = $(".section-2 .left-div") + $('.second-section-menu').on('click', function (e) { + sectionMenu.css("left", "0") + + $(document).one("click", function () { + sectionMenu.css("left", "-274px") + }); + + e.stopPropagation() + }) + + sectionMenu.on("click", function (e) { + e.stopPropagation(); + }) + } + + var useViewer = function () { + var viewer = new Viewer(document.querySelector('.md-body'), { + url: 'src' + }) + } + + var __main = function () { + getFileContributors() + bindClickMenu() + bindClickSecondMenu() + useViewer() + } + + __main() + + + + +
    -
    + + \ No newline at end of file diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 4638628bf..1373408d5 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -41,10 +41,14 @@ + {{ $version := index (strings.FindRE `v[0-9]+\.[0-9]+` .Page.RelPermalink) 0}} + +
    + {{ with (.GetPage "/docs") }}
    - {{ partial "section" . }} + {{ partial "section" (dict "context" . "ver" $version) }}
    {{ end }}
    @@ -54,6 +58,7 @@
    {{ partial "tree.html" . }} + - - {{ i18n - {{ i18n "Previous" }} - : {{.LinkTitle}} - - - {{ end }} - {{ with .Prev }} - - - - {{ end }} -
    + + + + {{ if .IsPage }} + + {{ partial "pagination" . }} + {{ end }}
    +
    {{ if .IsPage }}
    @@ -334,7 +326,7 @@ __main() - $(".asciicast").children().attr( "title", "video" ); + $(".asciicast").children().attr("title", "video"); @@ -349,16 +341,20 @@
    - + - - - + + +

    {{ i18n "KubeSphere®️ 2023 All Rights Reserved." }}

    diff --git a/layouts/partials/findFirstInSection.html b/layouts/partials/findFirstInSection.html new file mode 100644 index 000000000..26834e793 --- /dev/null +++ b/layouts/partials/findFirstInSection.html @@ -0,0 +1,9 @@ +{{ if ne .Parent.CurrentSection .Parent.FirstSection }} +{{ with .}} + +{{ end }} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/findLastInSection.html b/layouts/partials/findLastInSection.html new file mode 100644 index 000000000..65bad7447 --- /dev/null +++ b/layouts/partials/findLastInSection.html @@ -0,0 +1,23 @@ + +{{ if ne .Parent.CurrentSection .Parent.FirstSection }} + +{{ if .IsSection}} +{{ $curSection := .Pages.ByWeight }} +{{ $l := len $curSection}} +{{ $page := index $curSection (sub $l 1)}} +{{ partial "findLastInSection" $page}} + +{{ else }} + + + + + {{ i18n + {{ i18n "Previous" }} + : {{.LinkTitle}} + +{{ end }} + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/page_navigate.html b/layouts/partials/page_navigate.html new file mode 100644 index 000000000..e8da4271b --- /dev/null +++ b/layouts/partials/page_navigate.html @@ -0,0 +1,195 @@ + +{{ $current := .context }} + + + +{{ if $current.IsPage}} +{{ $g_parent := $current.Parent.Parent }} + + + + +{{ $p_section := $g_parent.Pages.ByWeight }} +{{ $length := len $p_section }} + + +{{ if .prev }} +{{ $first := index $p_section 0}} + + + + +{{ if $current.InSection $first.CurrentSection }} + + + + +{{ partial "page_navigate" (dict "context" $g_parent "prev" true)}} + + +{{else}} + + + +{{ $curIndex := 0 }} +{{ range $i, $p_sec := $p_section}} + +{{ if eq $p_sec $current.CurrentSection}} +{{ $curIndex = $i }} +{{ end }} +{{ end }} + + +{{ $prevPage := index $p_section (sub $curIndex 1) }} +{{ partial "findLastInSection" $prevPage}} + +{{ end }} + + + +{{ else }} + +{{ $last := index $p_section (sub $length 1)}} + + + +{{ if $current.InSection $last.CurrentSection }} + + + +{{ partial "page_navigate" (dict "context" $g_parent "prev" false)}} + + +{{ else }} + + +{{ $curIndex := 0 }} +{{ range $i, $p_sec := $p_section}} + +{{ if eq $p_sec $current.CurrentSection}} +{{ $curIndex = $i }} +{{ end }} +{{ end }} + + +{{ $nextPage := index $p_section (add $curIndex 1) }} +{{ partial "findFirstInSection" $nextPage}} + +{{ end }} + +{{ end }} + + + + +{{ else }} +{{ $g_parent := $current.Parent}} + +{{ $p_section := $g_parent.Pages.ByWeight }} +{{ $length := len $p_section }} + + +{{ if .prev}} +{{ $first := index $p_section 0}} + + + +{{ if $current.InSection $first.CurrentSection }} + +{{ partial "page_navigate" (dict "context" $g_parent "prev" true)}} + + +{{ else }} +{{ $curIndex := 0 }} +{{ range $i, $p_sec := $p_section}} + +{{ if eq $p_sec $current.CurrentSection}} +{{ $curIndex = $i }} +{{ end }} +{{ end }} + + +{{ $prevPage := index $p_section (sub $curIndex 1) }} +{{ partial "findLastInSection" $prevPage}} + +{{ end }} + + + +{{ else }} + +{{ $last := index $p_section (sub $length 1)}} + + + +{{ if $current.InSection $last.CurrentSection }} + + +{{ partial "page_navigate" (dict "context" $g_parent "prev" false)}} + + +{{ else }} + + +{{ $curIndex := 0 }} +{{ range $i, $p_sec := $p_section}} + +{{ if eq $p_sec $current.CurrentSection}} +{{ $curIndex = $i }} +{{ end }} +{{ end }} + + +{{ $nextPage := index $p_section (add $curIndex 1) }} +{{ partial "findFirstInSection" $nextPage}} + +{{ end }} + +{{ end }} + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 000000000..7c5c616b8 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,45 @@ + + +
    + + {{ $current := .}} + {{ $p := .Parent.Pages.ByWeight }} + {{ $length := len $p }} + + + + {{ $curIndex := 0 }} + {{ range $i, $p_sec := $p}} + + + + {{ if eq $p_sec $current}} + {{ $curIndex = $i }} + {{ end }} + {{ end }} + + + + + {{ if gt $curIndex 0}} + {{ $prevPage := index $p (sub $curIndex 1) }} + {{ partial "findLastInSection" $prevPage}} + {{ else }} + {{ partial "page_navigate" (dict "context" . "prev" true)}} + {{ end }} + + + + {{ if lt $curIndex (sub $length 1) }} + {{ $nextPage := index $p (add $curIndex 1)}} + {{ partial "findFirstInSection" $nextPage}} + {{ else }} + {{ partial "page_navigate" (dict "context" . "prev" false)}} + {{ end }} + +
    \ No newline at end of file diff --git a/layouts/partials/section.html b/layouts/partials/section.html index e8a5cb865..7f79c5d10 100644 --- a/layouts/partials/section.html +++ b/layouts/partials/section.html @@ -1,41 +1,23 @@ -{{ $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..9296fa421 --- /dev/null +++ b/layouts/partials/section_item.html @@ -0,0 +1,33 @@ +
  • +

    + {{ .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 diff --git a/layouts/partials/tree.html b/layouts/partials/tree.html index f0084095b..3d1655d44 100644 --- a/layouts/partials/tree.html +++ b/layouts/partials/tree.html @@ -1,22 +1,29 @@ + + + +
    -
    + + {{ define "section-tree-nav-section" }} {{ $s := .section }} {{ $p := .page }} {{ $list_active := $p.IsDescendant $s }} -{{ if eq $s.Parent $s.FirstSection }} + +{{ if eq $s.Parent $s.FirstSection }} {{ else }}

    @@ -25,7 +32,21 @@ {{ end }}

    {{ end }} + \ No newline at end of file From 929519b251df318997f236cfdabe47517c4fca02 Mon Sep 17 00:00:00 2001 From: ROOMrepair Date: Wed, 30 Oct 2024 22:08:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E9=A1=B5=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=92=8Chover=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ROOMrepair --- layouts/docs/second.html | 2 - layouts/docs/single.html | 3 - layouts/partials/page_navigate.html | 148 +++------------------------- layouts/partials/pagination.html | 11 --- 4 files changed, 13 insertions(+), 151 deletions(-) diff --git a/layouts/docs/second.html b/layouts/docs/second.html index b4914e049..b921cd500 100644 --- a/layouts/docs/second.html +++ b/layouts/docs/second.html @@ -157,8 +157,6 @@ - - {{ if .IsPage }} {{ partial "pagination" . }} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 1373408d5..aaf63dead 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -157,9 +157,6 @@ - - - {{ if .IsPage }} {{ partial "pagination" . }} diff --git a/layouts/partials/page_navigate.html b/layouts/partials/page_navigate.html index e8da4271b..2eff506bd 100644 --- a/layouts/partials/page_navigate.html +++ b/layouts/partials/page_navigate.html @@ -1,195 +1,73 @@ - {{ $current := .context }} - - -{{ if $current.IsPage}} -{{ $g_parent := $current.Parent.Parent }} + + +{{ $g_parent := "" }} +{{ if $current.IsPage }} +{{ $g_parent = $current.Parent.Parent }} +{{ else }} +{{ $g_parent = $current.Parent}} +{{ end }} - + {{ $p_section := $g_parent.Pages.ByWeight }} {{ $length := len $p_section }} - {{ if .prev }} {{ $first := index $p_section 0}} - {{ if $current.InSection $first.CurrentSection }} - - - {{ partial "page_navigate" (dict "context" $g_parent "prev" true)}} {{else}} - {{ $curIndex := 0 }} {{ range $i, $p_sec := $p_section}} - {{ if eq $p_sec $current.CurrentSection}} {{ $curIndex = $i }} {{ end }} {{ end }} - {{ $prevPage := index $p_section (sub $curIndex 1) }} {{ partial "findLastInSection" $prevPage}} {{ end }} - + {{ else }} + {{ $last := index $p_section (sub $length 1)}} - {{ if $current.InSection $last.CurrentSection }} - {{ partial "page_navigate" (dict "context" $g_parent "prev" false)}} {{ else }} - {{ $curIndex := 0 }} {{ range $i, $p_sec := $p_section}} - {{ if eq $p_sec $current.CurrentSection}} {{ $curIndex = $i }} {{ end }} {{ end }} - {{ $nextPage := index $p_section (add $curIndex 1) }} {{ partial "findFirstInSection" $nextPage}} -{{ end }} +{{ end }} + -{{ end }} - - - - -{{ else }} -{{ $g_parent := $current.Parent}} - -{{ $p_section := $g_parent.Pages.ByWeight }} -{{ $length := len $p_section }} - - -{{ if .prev}} -{{ $first := index $p_section 0}} - - - -{{ if $current.InSection $first.CurrentSection }} - -{{ partial "page_navigate" (dict "context" $g_parent "prev" true)}} - - -{{ else }} -{{ $curIndex := 0 }} -{{ range $i, $p_sec := $p_section}} - -{{ if eq $p_sec $current.CurrentSection}} -{{ $curIndex = $i }} {{ end }} -{{ end }} - -{{ $prevPage := index $p_section (sub $curIndex 1) }} -{{ partial "findLastInSection" $prevPage}} - -{{ end }} - - - -{{ else }} - -{{ $last := index $p_section (sub $length 1)}} - - - -{{ if $current.InSection $last.CurrentSection }} - - -{{ partial "page_navigate" (dict "context" $g_parent "prev" false)}} - - -{{ else }} - - -{{ $curIndex := 0 }} -{{ range $i, $p_sec := $p_section}} - -{{ if eq $p_sec $current.CurrentSection}} -{{ $curIndex = $i }} -{{ end }} -{{ end }} - - -{{ $nextPage := index $p_section (add $curIndex 1) }} -{{ partial "findFirstInSection" $nextPage}} - -{{ end }} - -{{ end }} - -{{ end }} \ No newline at end of file diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html index 7c5c616b8..0468f7034 100644 --- a/layouts/partials/pagination.html +++ b/layouts/partials/pagination.html @@ -1,5 +1,3 @@ - -
    {{ $current := .}} @@ -10,20 +8,11 @@ {{ $curIndex := 0 }} {{ range $i, $p_sec := $p}} - - - {{ if eq $p_sec $current}} {{ $curIndex = $i }} {{ end }} {{ end }} - {{ if gt $curIndex 0}}