]> juplo.de Git - maven-thymeleaf-skin/commitdiff
Publish-Datum und Projekt-Gewichtung hinzufügen
authorKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 16 Oct 2026 09:42:40 +0000 (09:42 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 16 Oct 2026 09:42:40 +0000 (09:42 +0000)
site.vm: Liest <published> und <weight> aus den <custom>-Parametern der
site.xml und gibt sie im stili-json aus.

import-in-astro.sh / import-in-hugo.sh:
- Neuer Schalter --published <YYYY-MM-DD> setzt das Publish-Datum explizit
  und übersteuert <published> aus site.xml.
- Fallback: heutiges Datum (date +%Y-%m-%d).
- <weight> aus site.xml steuert das weight-Feld der Root-_index.html
  und damit die Reihenfolge im Menü.
- Beide Werte werden im Frontmatter der Root-Seite (_index.html) gespeichert.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
src/main/resources/META-INF/maven/site.vm
src/main/resources/import-in-astro.sh
src/main/resources/import-in-hugo.sh

index 6b3e48136492371ad1cb089aa6f148b19c1968c4..7fff0a58d412f5cf92927b98e1f9b05c79c6b8fb 100644 (file)
@@ -75,6 +75,8 @@ $bodyContent
 ## Custom Variablen einlesen
 #set ( $menuName = $site.custom.getChild( 'menuName' ).getValue() )
 #set ( $debug = $site.custom.getChild( 'debug' ).getValue() )
+#set ( $published = $site.custom.getChild( 'published' ).getValue() )
+#set ( $weight = $site.custom.getChild( 'weight' ).getValue() )
 ## Die Root der Seiten-Hierarchie wird explizit erzeugt
 #if ($debug)
 <!-- PREPARING ROOT-ENTRY - name: $project.name ref: index.html -->
@@ -120,6 +122,12 @@ $bodyContent
   "version": "$project.version",
   "generator": "Apache Maven Doxia Site Renderer $!{doxiaSiteRendererVersion}",
   "generated": "$date.get("yyyy-MM-dd'T'HH:mm:ss'Z'")",
+#if ( $published )
+  "published": "$published",
+#end
+#if ( $weight )
+  "weight": $weight,
+#end
   "pages": [#set( $page_sep="")#foreach( $page in $pages )$page_sep
     {
 #if ( $page.name )
index 86433a9d74d4e22dfa41e67e5c4df71b79fb419f..2a6150761887bf8285c78d2c99afefd6bb6a18fe 100755 (executable)
@@ -2,7 +2,7 @@
 set -euo pipefail
 
 USAGE=$(
-  echo "Usage: $0 <ASTRO_ROOT> [--base <path>] [--project <name>] [ [--current [<url>]] | [--archived [<url>] [--canonical <url>]] ]";
+  echo "Usage: $0 <ASTRO_ROOT> [--base <path>] [--project <name>] [--published <date>] [ [--current [<url>]] | [--archived [<url>] [--canonical <url>]] ]";
   cat << EOF
 
   Imports a Maven site generated with the StILi skin into an Astro project.
@@ -13,6 +13,9 @@ USAGE=$(
               is appended as well.
 --project   : Overrides the project name used for URL and directory paths
               (Default: artifactId from the Maven project metadata).
+--published : Sets the published date (YYYY-MM-DD) written to the root page frontmatter.
+              Overrides <published> from src/site/site.xml.
+              Default: today's date.
 --current   : [DEFAULT]
               Marks this version as the current (visible) release.
               Content URL: <base>/<project>/page.html, params.current=true
@@ -43,6 +46,7 @@ shift
 
 BASE=""
 PROJECT=""
+PUBLISHED=""
 CURRENT=0
 ARCHIVED=0
 URL_BASE=""
@@ -67,6 +71,13 @@ while [[ $# -gt 0 ]]; do
       if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --project is missing!"; exit 1; fi
       PROJECT="${2%%/}"; PROJECT="${PROJECT##/}"; shift 2
       ;;
+    --published)
+      if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --published is missing!"; exit 1; fi
+      if [[ ! "$2" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
+        echo "ERROR -- --published requires a date in YYYY-MM-DD format"; exit 1
+      fi
+      PUBLISHED="$2"; shift 2
+      ;;
     --current)
       CURRENT=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
@@ -112,6 +123,11 @@ echo "$JSON" | jq -C .
 [[ -z "$PROJECT" ]] && PROJECT=$(echo "$JSON" | jq -r '.artifactId')
 VERSION=$(echo "$JSON" | jq -r '.version')
 
+JSON_PUBLISHED=$(echo "$JSON" | jq -r '.published // empty')
+JSON_WEIGHT=$(echo "$JSON" | jq -r '.weight // empty')
+[[ -z "$PUBLISHED" && -n "$JSON_PUBLISHED" ]] && PUBLISHED="$JSON_PUBLISHED"
+[[ -z "$PUBLISHED" ]] && PUBLISHED=$(date +%Y-%m-%d)
+
 if [[ -n "$URL_BASE" ]]; then
   URL_BASE="${URL_BASE%/}"
 elif [[ "$CURRENT_BOOL" == "true" ]]; then
@@ -139,6 +155,8 @@ echo "Version:   $VERSION"
 echo "Current:   $CURRENT_BOOL"
 echo "URL base:  $URL_BASE"
 [[ "$CURRENT_BOOL" == "false" ]] && echo "Canonical: $CANONICAL"
+echo "Published: $PUBLISHED"
+[[ -n "$JSON_WEIGHT" ]] && echo "Weight:    $JSON_WEIGHT"
 echo ""
 
 # Known generated-doc dirs (must match GENERATED_DOC_NAMES in src/lib/projects.ts)
@@ -166,6 +184,8 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
       TITLE_YAML=$(echo "$JSON" | jq '.project')
     fi
     DESCRIPTION_YAML=$(echo "$JSON" | jq '.description // empty')
+    PUBLISHED_YAML="$PUBLISHED"
+    [[ -n "$JSON_WEIGHT" ]] && WEIGHT="$JSON_WEIGHT"
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     ROUTING_FILE="index.astro"
@@ -173,6 +193,7 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
   else
     TITLE_YAML=$(echo "$PAGE" | jq '.name')
     DESCRIPTION_YAML=""
+    PUBLISHED_YAML=""
     HREF="$FILE"
     if [[ "$NUM_CHILDS" -gt 0 ]]; then
       CONTENT_REL="${PATH_PREFIX}${HREF%.html}/_index.html"
@@ -193,6 +214,7 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
     echo "weight: $WEIGHT"
     echo "url: $PAGE_URL"
     [[ -n "$DESCRIPTION_YAML" ]] && echo "description: $DESCRIPTION_YAML"
+    [[ -n "$PUBLISHED_YAML" ]] && echo "published: $PUBLISHED_YAML"
     echo "params:"
     echo "  current: $CURRENT_BOOL"
     [[ "$CURRENT_BOOL" == "false" ]] && echo "  canonical: $CANONICAL_URL"
index 77aa05d10f98e36626f3befb8ad68fbe5cb0e058..e31ef0769a9ba9e9ebcd6b2c7ede78166deb86e8 100755 (executable)
@@ -2,7 +2,7 @@
 set -euo pipefail
 
 USAGE=$(
-  echo "Usage: $0 <HUGO_ROOT> [--base <path>] [--project <name>] [ [--current [<url>]] | [--archived [<url>] [--canonical <url>]] ]";
+  echo "Usage: $0 <HUGO_ROOT> [--base <path>] [--project <name>] [--published <date>] [ [--current [<url>]] | [--archived [<url>] [--canonical <url>]] ]";
   cat << EOF
 
   Imports a Maven site generated with the StILi skin into a Hugo project.
@@ -12,6 +12,9 @@ USAGE=$(
               The project name and version are always appended.
 --project   : Overrides the project name used for URL and directory paths
               (Default: artifactId from the Maven project metadata).
+--published : Sets the published date (YYYY-MM-DD) written to the root page frontmatter.
+              Overrides <published> from src/site/site.xml.
+              Default: today's date.
 --current   : [DEFAULT]
               Marks this version as the current (visible) release.
               Content URL: <base>/<project>/page.html, params.current=true
@@ -40,6 +43,7 @@ shift
 
 BASE=""
 PROJECT=""
+PUBLISHED=""
 CURRENT=0
 ARCHIVED=0
 URL_BASE=""
@@ -60,6 +64,13 @@ while [[ $# -gt 0 ]]; do
       if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --project is missing!"; exit 1; fi
       PROJECT="${2%%/}"; PROJECT="${PROJECT##/}"; shift 2
       ;;
+    --published)
+      if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --published is missing!"; exit 1; fi
+      if [[ ! "$2" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
+        echo "ERROR -- --published requires a date in YYYY-MM-DD format"; exit 1
+      fi
+      PUBLISHED="$2"; shift 2
+      ;;
     --current)
       CURRENT=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
@@ -105,6 +116,11 @@ echo "$JSON" | jq -C .
 [[ -z "$PROJECT" ]] && PROJECT=$(echo "$JSON" | jq -r '.artifactId')
 VERSION=$(echo "$JSON" | jq -r '.version')
 
+JSON_PUBLISHED=$(echo "$JSON" | jq -r '.published // empty')
+JSON_WEIGHT=$(echo "$JSON" | jq -r '.weight // empty')
+[[ -z "$PUBLISHED" && -n "$JSON_PUBLISHED" ]] && PUBLISHED="$JSON_PUBLISHED"
+[[ -z "$PUBLISHED" ]] && PUBLISHED=$(date +%Y-%m-%d)
+
 PATH_BASE="$BASE/$PROJECT/$VERSION"
 
 if [[ -n "$URL_BASE" ]]; then
@@ -123,6 +139,8 @@ echo "Version:   $VERSION"
 echo "Current:   $CURRENT_BOOL"
 echo "URL base:  $URL_BASE"
 [[ "$CURRENT_BOOL" == "false" ]] && echo "Canonical: $CANONICAL"
+echo "Published: $PUBLISHED"
+[[ -n "$JSON_WEIGHT" ]] && echo "Weight:    $JSON_WEIGHT"
 echo ""
 
 for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html'); do
@@ -146,10 +164,13 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
     else
       TITLE_YAML=$(echo "$JSON" | jq '.project')
     fi
+    PUBLISHED_YAML="$PUBLISHED"
+    [[ -n "$JSON_WEIGHT" ]] && WEIGHT="$JSON_WEIGHT"
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     CANONICAL_URL="${CANONICAL}/"
   else
+    PUBLISHED_YAML=""
     TITLE_YAML=$(echo "$PAGE" | jq '.name')
     HREF="$FILE"
     if [[ "$NUM_CHILDS" -gt 0 ]]; then
@@ -168,6 +189,7 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
     echo "---"
     echo "title: $TITLE_YAML"
     echo "weight: $WEIGHT"
+    [[ -n "$PUBLISHED_YAML" ]] && echo "published: $PUBLISHED_YAML"
     echo "outputs:"
     echo "  - html"
     echo "url: $PAGE_URL"