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