global graph. not good

This commit is contained in:
Marcell Mars 2025-03-30 11:49:43 +02:00
parent 1331ed0e53
commit 21eefa76e9
5 changed files with 88 additions and 0 deletions

18
layouts/index.html Normal file
View file

@ -0,0 +1,18 @@
{{- $homepage := .Site.Params.home -}}
<!doctype html>
<html lang="en-us">
<head>
<title>{{ .Site.Title }}</title>
<link rel="canonical" href="{{ $homepage | absURL }}" />
<meta http-equiv="refresh" content="0; url={{ $homepage | absURL }}" />
<script>
window.location.href = "{{ $homepage | absURL }}";
</script>
</head>
<body>
<p>
If you are not redirected automatically, follow this
<a href="{{ $homepage | absURL }}">link</a>.
</p>
</body>
</html>

View file

@ -0,0 +1,25 @@
{{- $home := .Page.GetPage .Site.Params.home -}}
<div class="header">
<a
title="{{ $home.Title }}'s Bibliotheke"
href="{{ "library/BROWSE_LIBRARY.html" | relURL }}"
class="bibliotheke"
target="_blank"
>
<img src="{{ "images/bibliotheke.svg" | relURL }}" />
</a>
<div class="breadcrumbs">
<a href="{{ $home.RelPermalink }}">
<i>{{ $home.Title }}</i>
</a>
{{- if ne $home.Title .Page.Title -}}
»&nbsp;
<a href="{{ .Page.RelPermalink }}">
<i>{{ .Page.Title }}</i>
</a>
{{- end -}}
</div>
</div>
<pre>{{ debug.Dump .Site.Params }}</pre>

View file

@ -0,0 +1,4 @@
{{- with templates.Defer -}}
{{- $globalGraph := site.Home.Store.Get "graph" -}}
{{- warnf "%s" ($globalGraph | jsonify (dict "prefix" " " "indent" " ")) -}}
{{- end -}}

View file

@ -0,0 +1,40 @@
{{- $currentPage := . -}}
{{- $sectionMap := site.Data.sandpointsnamegraph -}}
{{ $currentEntry := dict }}
{{- $menuPrefix := "" -}}
{{- $section := "" -}}
{{- range $sectionMaybe, $pages := $currentPage.Params -}}
{{- if strings.Contains $sectionMaybe "_" -}}
{{- $sectionsSlice := split (strings.TrimPrefix "_" $sectionMaybe) "_" -}}
{{- if gt (len $sectionsSlice) 0 -}}
{{- $pluralSection := index (last 1 $sectionsSlice) 0 -}}
{{- range $singular, $plural := $sectionMap -}}
{{- if eq $plural $pluralSection -}}
{{- $section = $singular -}}
{{- end -}}
{{- end -}}
{{- where site.Pages "Section" $section -}}
{{- $menuPrefix = "no-prefix" -}}
{{- if gt (len $sectionsSlice) 1 -}}
{{- $menuPrefix = delimit (first (sub (len $sectionsSlice) 1) $sectionsSlice) " " -}}
{{- else -}}
{{- end -}}
{{- if reflect.IsSlice $pages -}}
{{- range $page := $pages -}}
{{- with site.GetPage (printf "%s/%s" $section $page) -}}
{{- $currentPrefix := index $currentEntry $currentPage.RelPermalink | default (dict $menuPrefix slice) -}}
{{- $currentPages := index $currentPrefix $menuPrefix | default (slice .RelPermalink) -}}
{{- $currentPages = $currentPages | append .RelPermalink -}}
{{- $currentPrefix = merge $currentPrefix (dict $menuPrefix (uniq $currentPages)) -}}
{{- $currentEntry = merge $currentEntry (dict $currentPage.RelPermalink $currentPrefix) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if gt (len $currentEntry) 0 -}}
{{- site.Home.Store.SetInMap "graph" $currentPage.RelPermalink $currentEntry -}}
{{- end -}}

View file

@ -0,0 +1 @@
{{ with site.GetPage (.Get 0) }} {{ .RenderShortcodes }} {{ end }}