mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-22 23:37:53 +00:00
arrownav: inline meta calculation #685
This commit is contained in:
parent
3a2118a89d
commit
828a44d347
8 changed files with 168 additions and 69 deletions
|
@ -1,4 +1,3 @@
|
|||
{{- partialCached "relearn-meta.gotmpl" . .Path }}
|
||||
{{- $pages := slice }}
|
||||
{{- range .Site.Pages }}
|
||||
{{- if partial "_relearn/pageIsSpecial.gotmpl" . }}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{{- partialCached "relearn-meta.gotmpl" . .Path -}}
|
||||
<!DOCTYPE html>
|
||||
{{- .Store.Set "relearnOutputFormat" "notfound" }}
|
||||
<html lang="{{ .Page.Language.LanguageCode }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}" itemscope itemtype="http://schema.org/Article">
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
{{- partialCached "relearn-meta.gotmpl" . .Path -}}
|
||||
<!DOCTYPE html>
|
||||
{{- block "storeOutputFormat" . }}{{ end }}
|
||||
{{- if .IsHome }}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{- /* based on Hugo 0.125.5 rss.xml */}}
|
||||
{{- partialCached "relearn-meta.gotmpl" . .Path }}
|
||||
{{- /* Deprecate site.Author.email in favor of site.Params.author.email */}}
|
||||
{{- $authorEmail := "" }}
|
||||
{{- if and .Site.Params.author (reflect.IsMap .Site.Params.author) .Site.Params.author.email }}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{{- /* based on Hugo 0.125.5 sitemap.xml */}}
|
||||
{{- partialCached "relearn-meta.gotmpl" . .Path }}
|
||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||
{{- range where .Pages "Sitemap.Disable" "ne" true }}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{{- $pages := partialCached "partials/_relearn/pagesTaxonomy.gotmpl" . .Path }}
|
||||
{{- $next = (index $pages 0).Page }}
|
||||
{{- else }}
|
||||
{{- $next = .Scratch.Get "relearnNextPage" }}
|
||||
{{- $next = partial "inline/next-page" . }}
|
||||
{{- end }}
|
||||
{{- return $next }}
|
||||
|
||||
|
@ -27,4 +27,93 @@
|
|||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next-page" }}
|
||||
{{- $nextVisible := "" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $currentNode) $currentNode.Path }}
|
||||
{{- range $pages }}
|
||||
{{- $nextVisible = partial "inline/leftmost_descendant" . }}
|
||||
{{- if $nextVisible }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $nextVisible }}
|
||||
{{- $nextVisible = partial "inline/next_sibling_or_ancestor" $currentNode }}
|
||||
{{- end }}
|
||||
{{- return $nextVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next_sibling_or_ancestor" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- $nextSibling := "" }}
|
||||
{{- with partial "inline/parent" $currentNode }}
|
||||
{{- $parent := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $parent) $parent.Path }}
|
||||
{{- $nextVisible := partial "inline/next_sibling" (dict "siblings" $pages "currentNode" $currentNode) }}
|
||||
{{- if $nextVisible }}
|
||||
{{- $nextSibling = partial "inline/leftmost_descendant" $nextVisible }}
|
||||
{{- if not $nextSibling }}
|
||||
{{- $nextSibling = partial "inline/next_sibling_or_ancestor" $parent }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $nextSibling = partial "inline/next_sibling_or_ancestor" $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nextSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/next_sibling" }}
|
||||
{{- $siblings := .siblings }}
|
||||
{{- $currentNode := .currentNode }}
|
||||
{{- $nextSibling := "" }}
|
||||
{{- $currentFound := false }}
|
||||
{{- range $siblings }}
|
||||
{{- if eq . $currentNode }}
|
||||
{{- $currentFound = true }}
|
||||
{{- else if $currentFound }}
|
||||
{{- $nextSibling = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nextSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/leftmost_descendant" }}
|
||||
{{- $leftmostVisible := "" }}
|
||||
{{- if not (or (.Params.hidden) (eq .Title "")) }}
|
||||
{{- if .RelPermalink }}
|
||||
{{- $leftmostVisible = . }}
|
||||
{{- else }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- with partial "inline/leftmost_descendant" . }}
|
||||
{{- $leftmostVisible = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $leftmostVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/parent" }}
|
||||
{{- $nonheadless := "" }}
|
||||
{{- $page := . }}
|
||||
{{- $parent := .Parent }}
|
||||
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
||||
{{- with $parent }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- if eq . $page }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nonheadless }}
|
||||
{{- end }}
|
|
@ -9,7 +9,7 @@
|
|||
{{- else if eq .Page.Kind "home" }}
|
||||
{{- /* no prev here */}}
|
||||
{{- else }}
|
||||
{{- $prev = .Scratch.Get "relearnPrevPage" }}
|
||||
{{- $prev = or (partial "inline/prev_page" .) .Site.Home }}
|
||||
{{- end }}
|
||||
{{- return $prev }}
|
||||
|
||||
|
@ -26,4 +26,81 @@
|
|||
{{- $last = .Page.Page }}
|
||||
{{- end }}
|
||||
{{- return $result }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/prev_page" }}
|
||||
{{- $previousVisible := "" }}
|
||||
{{- $currentNode := . }}
|
||||
{{- with partial "inline/parent" $currentNode }}
|
||||
{{- $parent := . }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" $parent) $parent.Path }}
|
||||
{{- $previousSibling := partial "inline/prev_sibling" (dict "siblings" $pages "currentNode" $currentNode) }}
|
||||
{{- if $previousSibling }}
|
||||
{{- $previousVisible = partial "inline/rightmost_descendant" $previousSibling }}
|
||||
{{- if not $previousVisible }}
|
||||
{{- if $previousSibling.RelPermalink }}
|
||||
{{- $previousVisible = $previousSibling }}
|
||||
{{- else }}
|
||||
{{- $previousVisible = partial "inline/prev_page" $previousSibling }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if $parent.RelPermalink }}
|
||||
{{- $previousVisible = $parent }}
|
||||
{{- else }}
|
||||
{{- $previousVisible = partial "inline/prev_page" $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $previousVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/prev_sibling" }}
|
||||
{{- $previousSibling := "" }}
|
||||
{{- $siblings := .siblings }}
|
||||
{{- $currentNode := .currentNode }}
|
||||
{{- range $siblings }}
|
||||
{{- if eq . $currentNode }}
|
||||
{{- break }}
|
||||
{{- else if not (or (.Params.hidden) (eq .Title "")) }}
|
||||
{{- $previousSibling = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $previousSibling }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/rightmost_descendant" }}
|
||||
{{- $rightmostVisible := . }}
|
||||
{{- $pages := (partialCached "_relearn/pages.gotmpl" (dict "page" $rightmostVisible) $rightmostVisible.Path) | collections.Reverse }}
|
||||
{{- range $pages }}
|
||||
{{- if not (or (.Params.hidden) (eq .Title "")) }}
|
||||
{{- with partial "inline/rightmost_descendant" . }}
|
||||
{{- if .RelPermalink }}
|
||||
{{- $rightmostVisible = . }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $rightmostVisible }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "partials/inline/parent" }}
|
||||
{{- $nonheadless := "" }}
|
||||
{{- $page := . }}
|
||||
{{- $parent := .Parent }}
|
||||
{{- if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
||||
{{- with $parent }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .) .Path }}
|
||||
{{- range $pages }}
|
||||
{{- if eq . $page }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $nonheadless = $parent }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- return $nonheadless }}
|
||||
{{- end }}
|
|
@ -1,62 +0,0 @@
|
|||
<!--
|
||||
@@@
|
||||
lang: {{- .Site.LanguagePrefix }}
|
||||
path: {{- .Path }}
|
||||
kind: {{- .Kind }} ["home" "page" "section" "taxonomy" "term"]
|
||||
layout: {{- .Layout }}
|
||||
type: {{- .Type }} [frontmatter:type section "page"]
|
||||
section: {{- .Section }}
|
||||
@@@
|
||||
-->
|
||||
{{- $currentNode := . }}
|
||||
{{- $forceContent := $currentNode.WordCount }}
|
||||
{{- $currentNode.Scratch.Delete "relearnIsSelfFound" }}
|
||||
{{- $currentNode.Scratch.Delete "relearnPrevPage" }}
|
||||
{{- $currentNode.Scratch.Delete "relearnNextPage" }}
|
||||
{{- if (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
|
||||
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }}
|
||||
{{- if not ($currentNode.Scratch.Get "relearnIsSelfFound") }}
|
||||
{{- if not $currentNode.IsHome }}
|
||||
{{- $currentNode.Scratch.Set "relearnPrevPage" .Site.Home }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "relearn-structure" }}
|
||||
{{- $currentNode := .currentnode }}
|
||||
{{- $isSelf := eq $currentNode .node }}
|
||||
{{- $isDescendant := and (not $isSelf) (.node.IsDescendant $currentNode) }}
|
||||
{{- $isAncestor := and (not $isSelf) (.node.IsAncestor $currentNode) }}
|
||||
{{- $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
|
||||
{{- $isChildren := eq $currentNode .node.Parent }}
|
||||
{{- if $isSelf }}
|
||||
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
|
||||
{{- end }}
|
||||
{{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }}
|
||||
{{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
|
||||
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
|
||||
|
||||
{{- $hidden_node := or (.node.Params.hidden) (eq .node.Title "") }}
|
||||
{{- $hidden_stem := or $hidden_node .hiddenstem }}
|
||||
{{- $hidden_from_current := or (and $hidden_node (not $isAncestor) (not $isSelf) ) (and .hiddencurrent (or $isPreSelf $isPostSelf $isDescendant) ) }}
|
||||
|
||||
{{- if or (eq $currentNode.Kind "home") (eq $currentNode.Kind "section") (eq $currentNode.Kind "page") }}
|
||||
{{- if not $hidden_from_current }}
|
||||
{{- if and $isPreSelf .node.RelPermalink }}
|
||||
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
|
||||
{{- else if and $isPostSelf .node.RelPermalink (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
|
||||
{{- $currentNode.Scratch.Set "relearnNextPage" .node }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if not ($currentNode.Scratch.Get "relearnNextPage") }}
|
||||
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .node) .node.Path }}
|
||||
{{- range $pages }}
|
||||
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current }}
|
||||
{{- if $currentNode.Scratch.Get "relearnNextPage" }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
Loading…
Reference in a new issue