From 29ec7412c990a34a98defb249f96d7873ba06b1b Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 16 Oct 2026 09:42:40 +0000 Subject: [PATCH] =?utf8?q?Publish-Datum=20und=20Projekt-Gewichtung=20hinzu?= =?utf8?q?f=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit site.vm: Liest und aus den -Parametern der site.xml und gibt sie im stili-json aus. import-in-astro.sh / import-in-hugo.sh: - Neuer Schalter --published setzt das Publish-Datum explizit und übersteuert aus site.xml. - Fallback: heutiges Datum (date +%Y-%m-%d). - 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 --- src/main/resources/META-INF/maven/site.vm | 8 ++++++++ src/main/resources/import-in-astro.sh | 24 ++++++++++++++++++++++- src/main/resources/import-in-hugo.sh | 24 ++++++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm index 6b3e481..7fff0a5 100644 --- a/src/main/resources/META-INF/maven/site.vm +++ b/src/main/resources/META-INF/maven/site.vm @@ -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) @@ -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 ) diff --git a/src/main/resources/import-in-astro.sh b/src/main/resources/import-in-astro.sh index 86433a9..2a61507 100755 --- a/src/main/resources/import-in-astro.sh +++ b/src/main/resources/import-in-astro.sh @@ -2,7 +2,7 @@ set -euo pipefail USAGE=$( - echo "Usage: $0 [--base ] [--project ] [ [--current []] | [--archived [] [--canonical ]] ]"; + echo "Usage: $0 [--base ] [--project ] [--published ] [ [--current []] | [--archived [] [--canonical ]] ]"; 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 from src/site/site.xml. + Default: today's date. --current : [DEFAULT] Marks this version as the current (visible) release. Content URL: //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" diff --git a/src/main/resources/import-in-hugo.sh b/src/main/resources/import-in-hugo.sh index 77aa05d..e31ef07 100755 --- a/src/main/resources/import-in-hugo.sh +++ b/src/main/resources/import-in-hugo.sh @@ -2,7 +2,7 @@ set -euo pipefail USAGE=$( - echo "Usage: $0 [--base ] [--project ] [ [--current []] | [--archived [] [--canonical ]] ]"; + echo "Usage: $0 [--base ] [--project ] [--published ] [ [--current []] | [--archived [] [--canonical ]] ]"; 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 from src/site/site.xml. + Default: today's date. --current : [DEFAULT] Marks this version as the current (visible) release. Content URL: //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" -- 2.39.5