From 929519b251df318997f236cfdabe47517c4fca02 Mon Sep 17 00:00:00 2001 From: ROOMrepair Date: Wed, 30 Oct 2024 22:08:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E9=A1=B5=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98=E5=92=8C?= =?UTF-8?q?hover=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}}