The JSON is rendered in the page and picked up there by thymeleaf
authorKai Moritz <kai@juplo.de>
Sun, 28 Feb 2021 19:44:44 +0000 (20:44 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 28 Feb 2021 20:26:10 +0000 (21:26 +0100)
src/main/resources/META-INF/maven/site.vm
src/site/site.xml

index 1e336ed..b81690c 100644 (file)
       uri='$sitePath$alignedFileName',
       title=~{:: title},
       maincontent=~{:: .maincontent},
-      json='MERGE:
-      {
-        &quot;_titles&quot;: {
-          #set($sep = "")
-          #foreach($page in $pages)
-            $sep
-            &quot;$sitePath$page.uri&quot;: &quot;$page.name&quot;
-            #set($sep = ",")
-          #end
-        },
-        &quot;_childs&quot;: {
-          #set($sep = "")
-          #foreach($page in $pages)
-            #if(!$page.childs.isEmpty())
-              $sep
-              &quot;$sitePath$page.uri&quot;: [
-                #set($csep = "")
-                #foreach($child in $page.childs.entrySet())
-                  $csep
-                  &quot;$sitePath$child.key&quot;
-                  #set($csep = ",")
-                #end
-              ]
-              #set($sep = ",")
-            #end
-          #end
-        },
-        &quot;_crumbs&quot;: {
-          #set($sep = "")
-          #foreach($page in $pages)
-            $sep
-            &quot;$sitePath$page.uri&quot;: [
-              #set($csep = "")
-              #if($siteCrumbs)
-                $siteCrumbs
-                #set($csep = ",")
-              #end
-              #set($last = "")
-              #foreach($crumb in $page.crumbs)
-                #if($sitePath+$crumb.uri != $last)
-                  $csep
-                  &quot;$sitePath$crumb.uri&quot;
-                  #set($csep = ",")
-                  #set($last = $sitePath+$crumb.uri)
-                #end
-              #end
-            ]
-            #set($sep = ",")
-          #end
-        }
-      }
-      ')}"
-    >
+      json='MERGE:' + ~{:: pre[class='json']/text()})}" >
   <head>
     <title id="title">#if($shortTitle and $shortTitle != '')$title#else$project.name &mdash; $pages.get($alignedFileName).name#end</title>
     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />
       $bodyContent
     </article>
     <hr />
-    <h2>Pages</h2>
+    <h2>Page Structure as JSON</h2>
+    <pre class="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
+
+  }
+}
+    </pre>
+    <h2>All Pages</h2>
     <p>
       <ul>
         #foreach($page in $pages)<li><a href="$page.uri">$page.name</a></li>#end
index f14724a..8295a60 100644 (file)
@@ -24,7 +24,7 @@
   <custom>
     <thymeproxy>
       <path>/maven-thymeleaf-skin/</path>
-      <crumbs><![CDATA[&quot;/projects.html&quot;]]></crumbs>
+      <crumbs>"/index.html","/projects.html"</crumbs>
     </thymeproxy>
   </custom>
 </project>