From 73b5e8c984163e4fe64c437f9bd5736907e5b80c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 28 Feb 2021 20:44:44 +0100 Subject: [PATCH] The JSON is rendered in the page and picked up there by thymeleaf --- src/main/resources/META-INF/maven/site.vm | 82 ++++++++--------------- src/site/site.xml | 2 +- 2 files changed, 29 insertions(+), 55 deletions(-) diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm index 1e336ed..b81690c 100644 --- a/src/main/resources/META-INF/maven/site.vm +++ b/src/main/resources/META-INF/maven/site.vm @@ -141,59 +141,7 @@ uri='$sitePath$alignedFileName', title=~{:: title}, maincontent=~{:: .maincontent}, - json='MERGE: - { - "_titles": { - #set($sep = "") - #foreach($page in $pages) - $sep - "$sitePath$page.uri": "$page.name" - #set($sep = ",") - #end - }, - "_childs": { - #set($sep = "") - #foreach($page in $pages) - #if(!$page.childs.isEmpty()) - $sep - "$sitePath$page.uri": [ - #set($csep = "") - #foreach($child in $page.childs.entrySet()) - $csep - "$sitePath$child.key" - #set($csep = ",") - #end - ] - #set($sep = ",") - #end - #end - }, - "_crumbs": { - #set($sep = "") - #foreach($page in $pages) - $sep - "$sitePath$page.uri": [ - #set($csep = "") - #if($siteCrumbs) - $siteCrumbs - #set($csep = ",") - #end - #set($last = "") - #foreach($crumb in $page.crumbs) - #if($sitePath+$crumb.uri != $last) - $csep - "$sitePath$crumb.uri" - #set($csep = ",") - #set($last = $sitePath+$crumb.uri) - #end - #end - ] - #set($sep = ",") - #end - } - } - ')}" - > + json='MERGE:' + ~{:: pre[class='json']/text()})}" > #if($shortTitle and $shortTitle != '')$title#else$project.name — $pages.get($alignedFileName).name#end @@ -211,7 +159,33 @@ $bodyContent
-

Pages

+

Page Structure as JSON

+
+{
+  "_titles": {#set($sep = "")#foreach($page in $pages)$sep
+    "$sitePath$page.uri": "$page.name"#set($sep = ",")
+#end
+
+  },
+  "_childs": {#set($sep = "")#foreach($page in $pages)#if(!$page.childs.isEmpty())$sep
+    "$sitePath$page.uri": [#set($csep = "")#foreach($child in $page.childs.entrySet())$csep
+      "$sitePath$child.key"#set($csep = ",")#end
+
+    ]#set($sep = ",")#end#end
+
+  },
+  "_crumbs": {#set($sep = "")#foreach($page in $pages)$sep
+    "$sitePath$page.uri": [
+#set($csep = "")#if($siteCrumbs)
+      $siteCrumbs#set($csep = ",")#end#set($last = "")#foreach($crumb in $page.crumbs)#if($sitePath+$crumb.uri != $last)$csep
+      "$sitePath$crumb.uri"#set($csep = ",")#set($last = $sitePath+$crumb.uri)#end#end
+
+    ]#set($sep = ",")#end
+
+  }
+}
+    
+

All Pages