From 80f451e842016145409fb5b7bdaaecb5b2c0d863 Mon Sep 17 00:00:00 2001 From: Marcell Mars Date: Thu, 3 Apr 2025 16:24:20 +0200 Subject: [PATCH] initial mentioned_in and isin menus... --- layouts/partials/GetPluralSectionName.html | 2 ++ layouts/partials/GetSingularSectionName.html | 9 ++++++++ layouts/partials/deferred_page_graph.html | 7 ++---- layouts/partials/mentioned_in.html | 12 ++++++++++ layouts/partials/menu_isin.html | 24 ++++++++++++++++++++ layouts/partials/single-page-graph.html | 7 +----- 6 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 layouts/partials/GetPluralSectionName.html create mode 100644 layouts/partials/GetSingularSectionName.html create mode 100644 layouts/partials/mentioned_in.html create mode 100644 layouts/partials/menu_isin.html diff --git a/layouts/partials/GetPluralSectionName.html b/layouts/partials/GetPluralSectionName.html new file mode 100644 index 0000000..29cafb7 --- /dev/null +++ b/layouts/partials/GetPluralSectionName.html @@ -0,0 +1,2 @@ +{{- $sectionMap := site.Data.sandpointsnamegraph -}}{{- return index $sectionMap +. -}} diff --git a/layouts/partials/GetSingularSectionName.html b/layouts/partials/GetSingularSectionName.html new file mode 100644 index 0000000..a67b69b --- /dev/null +++ b/layouts/partials/GetSingularSectionName.html @@ -0,0 +1,9 @@ +{{- $pluralSection := . -}} +{{- $sectionMap := site.Data.sandpointsnamegraph -}} +{{- $section := "" -}} +{{- range $singular, $plural := $sectionMap -}} + {{- if eq $plural $pluralSection -}} + {{- $section = $singular -}} + {{- end -}} +{{- end -}} +{{- return $section -}} diff --git a/layouts/partials/deferred_page_graph.html b/layouts/partials/deferred_page_graph.html index 9d0eb15..8c483ee 100644 --- a/layouts/partials/deferred_page_graph.html +++ b/layouts/partials/deferred_page_graph.html @@ -1,6 +1,5 @@ {{ $currentPage := . }} {{ $currentPageGraph := $currentPage.Store.Get "graph"}} -

{{ printf "%#v" $currentPageGraph }}

{{ $data := (dict "allPages" site.AllPages "currentPage" $currentPage)}} {{- with (templates.Defer (dict "data" $data)) -}} @@ -23,8 +22,6 @@ {{- end -}} {{- end -}} - {{- printf "%s is in %#v" .currentPage.RelPermalink (.currentPage.Store.Get "isin") -}} - {{- printf "%s mentioned in %#v" .currentPage.RelPermalink (.currentPage.Store.Get "mentioned_in") -}} - {{- warnf "%s is in %#v" .currentPage.RelPermalink (.currentPage.Store.Get "isin") -}} - {{- warnf "%s mentioned in %#v" .currentPage.RelPermalink (.currentPage.Store.Get "mentioned_in") -}} + {{- partial "menu_isin.html" (dict "currentPage" .currentPage "isin" (.currentPage.Store.Get "isin")) -}} + {{- partial "mentioned_in.html" (dict "currentPage" .currentPage "mentioned_in" (.currentPage.Store.Get "mentioned_in")) -}} {{- end -}} diff --git a/layouts/partials/mentioned_in.html b/layouts/partials/mentioned_in.html new file mode 100644 index 0000000..6962192 --- /dev/null +++ b/layouts/partials/mentioned_in.html @@ -0,0 +1,12 @@ +
+
mentioned in⁄
+
+ {{- $currentPage := .currentPage -}} {{- range .mentioned_in -}}{{- $p := + site.GetPage . -}} +
+ {{- $p.LinkTitle -}} +

{{- printf "RELREF: %#v" (relref $currentPage $p.RelPermalink) -}}

+
+ {{- end -}} +
+
diff --git a/layouts/partials/menu_isin.html b/layouts/partials/menu_isin.html new file mode 100644 index 0000000..dc7d363 --- /dev/null +++ b/layouts/partials/menu_isin.html @@ -0,0 +1,24 @@ +{{- $sections := slice -}} +{{- $currentPage := .currentPage -}} +{{- $isin := .isin -}} +{{- range $isin -}} + {{- $p := site.GetPage . -}} + {{- $section := trim $p.FirstSection.RelPermalink "//" -}} + {{- $sections = uniq ($sections | append $section) -}} +{{- end -}} +
+ {{- range $sections -}} + {{- $section := . -}} +
is in {{- partial "GetPluralSectionName.html" $section -}}⁄
+
+ {{- range $isin -}} + {{- $p := site.GetPage . -}} + {{- if eq (trim $p.FirstSection.RelPermalink "//") $section -}} +
+ {{- $p.LinkTitle -}} +
+ {{- end -}} + {{- end -}} +
+ {{- end -}} +
diff --git a/layouts/partials/single-page-graph.html b/layouts/partials/single-page-graph.html index 4ead7ed..2bb604b 100644 --- a/layouts/partials/single-page-graph.html +++ b/layouts/partials/single-page-graph.html @@ -1,5 +1,4 @@ {{- $currentPage := . -}} -{{- $sectionMap := site.Data.sandpointsnamegraph -}} {{ $currentEntry := dict }} @@ -10,11 +9,7 @@ {{- $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 -}} + {{- $section = partial "GetSingularSectionName.html" $pluralSection -}} {{- where site.Pages "Section" $section -}} {{- $menuPrefix = "no-prefix" -}} {{- if gt (len $sectionsSlice) 1 -}}