SandpointsTheme/layouts/partials/deferred_page_graph.html

31 lines
1.5 KiB
HTML

{{ $currentPage := . }}
{{ $currentPageGraph := $currentPage.Store.Get "graph"}}
{{ $data := (dict "allPages" site.AllPages "currentPage" $currentPage)}}
{{- with (templates.Defer (dict "data" $data)) -}}
{{ range $page := .allPages }}
{{- $pageGraph := $page.Store.Get "graph" -}}
{{- range $child := index $pageGraph "has" -}}
{{- $childPage := site.GetPage $child -}}
{{- $isinPages := $childPage.Store.Get "isin" | default slice -}}
{{- $isinPages = $isinPages | append $page.RelPermalink -}}
{{- $childPage.Store.Set "isin" ($isinPages|uniq) -}}
{{- end -}}
{{- range $kid := index $pageGraph "no-prefix" -}}
{{- $mentionedInPage := site.GetPage $kid -}}
{{- $mentionedIn := $mentionedInPage.Store.Get "mentioned_in" | default slice -}}
{{- $mentionedIn = $mentionedIn | append $page.RelPermalink -}}
{{- $mentionedInPage.Store.Set "mentioned_in" ($mentionedIn|uniq) -}}
{{- end -}}
{{- end -}}
{{- $isin := .currentPage.Store.Get "isin" -}}
{{- $backreferences := union (.currentPage.Store.Get "mentioned_in") (.currentPage.Store.Get "backlinks") -}}
{{- $complement := slice -}}
{{- with $backreferences -}}
{{- $complement = $backreferences -}}
{{- with $isin -}}
{{- $complement = complement $isin $backreferences -}}
{{- end -}}
{{- end -}}
{{- partial "menu_isin.html" (dict "currentPage" .currentPage "isin" $isin) -}}
{{- partial "menu_mentioned_in.html" (dict "currentPage" .currentPage "mentioned_in" $complement) -}}
{{- end -}}