]> juplo.de Git - maven-thymeleaf-skin/commitdiff
Fix three regressions introduced by the previous simplification
authorKai Moritz <kai.milan.moritz@googlemail.com>
Wed, 17 Jun 2026 16:09:02 +0000 (16:09 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Wed, 17 Jun 2026 16:09:02 +0000 (16:09 +0000)
1. URL normalization: "/${VAR##//}" strips the leading slash when the
   input already starts with "/". Fix: strip trailing and leading slash
   separately, then prepend "/": VAR="${2%%/}"; VAR="/${VAR##/}".
   Affects --current, --archived, and --canonical in both scripts.
   Consequences: missing leading "/" in frontmatter url/canonical fields
   (Hugo+Astro) and in the static-copy destination path (Hugo).

2. Root page title (Hugo+Astro): TITLE_YAML was unified to use
   $PAGE | jq '.name' for all pages. For index.html the Maven project
   name must come from $JSON | jq '.project', not from the site.xml
   page name. Moved TITLE_YAML assignment into the if/else branches.

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

index 96b4d815081370b792666d97459d8b4aee9969b2..fad7c75406040134f486ecce95809fd44e60290b 100755 (executable)
@@ -60,7 +60,7 @@ while [[ $# -gt 0 ]]; do
     --current)
       CURRENT=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
-        URL_BASE="/${2%%/}"; URL_BASE="${URL_BASE##//}"; shift 2
+        URL_BASE="${2%%/}"; URL_BASE="/${URL_BASE##/}"; shift 2
       else
         shift
       fi
@@ -68,14 +68,14 @@ while [[ $# -gt 0 ]]; do
     --archived)
       ARCHIVED=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
-        URL_BASE="/${2%%/}"; URL_BASE="${URL_BASE##//}"; shift 2
+        URL_BASE="${2%%/}"; URL_BASE="/${URL_BASE##/}"; shift 2
       else
         shift
       fi
       ;;
     --canonical)
       if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --canonical is missing!"; exit 1; fi
-      CANONICAL="/${2%%/}"; CANONICAL="${CANONICAL##//}"; shift 2
+      CANONICAL="${2%%/}"; CANONICAL="/${CANONICAL##/}"; shift 2
       ;;
     *)
       echo "ERROR -- Unknown parameter: $1"; echo; echo "$USAGE"; exit 1
@@ -149,14 +149,15 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
   PATH_PREFIX=$(echo "$PAGE" | jq -r '.path')
   [[ -n "$PATH_PREFIX" && "${PATH_PREFIX: -1}" != "/" ]] && PATH_PREFIX="${PATH_PREFIX}/"
   NUM_CHILDS=$(echo "$PAGE" | jq '.childs | length')
-  TITLE_YAML=$(echo "$PAGE" | jq '.name')
 
   if [[ "$FILE" == "index.html" ]]; then
+    TITLE_YAML=$(echo "$JSON" | jq '.project')
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     ROUTING_FILE="index.astro"
     CANONICAL_URL="${CANONICAL}/"
   else
+    TITLE_YAML=$(echo "$PAGE" | jq '.name')
     HREF="$FILE"
     if [[ "$NUM_CHILDS" -gt 0 ]]; then
       CONTENT_REL="${PATH_PREFIX}${HREF%.html}/_index.html"
index 3ed56a4e937053288f574351e4a9f99863596b01..1540bb20ec3f88dd36dd23e7bc078607aaec4724 100755 (executable)
@@ -63,7 +63,7 @@ while [[ $# -gt 0 ]]; do
     --current)
       CURRENT=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
-        URL_BASE="/${2%%/}"; URL_BASE="${URL_BASE##//}"; shift 2
+        URL_BASE="${2%%/}"; URL_BASE="/${URL_BASE##/}"; shift 2
       else
         shift
       fi
@@ -71,14 +71,14 @@ while [[ $# -gt 0 ]]; do
     --archived)
       ARCHIVED=1
       if [[ $# -ge 2 && ! "$2" =~ ^-- ]]; then
-        URL_BASE="/${2%%/}"; URL_BASE="${URL_BASE##//}"; shift 2
+        URL_BASE="${2%%/}"; URL_BASE="/${URL_BASE##/}"; shift 2
       else
         shift
       fi
       ;;
     --canonical)
       if [[ $# -lt 2 ]]; then echo "ERROR -- Parameter for --canonical is missing!"; exit 1; fi
-      CANONICAL="/${2%%/}"; CANONICAL="${CANONICAL##//}"; shift 2
+      CANONICAL="${2%%/}"; CANONICAL="/${CANONICAL##/}"; shift 2
       ;;
     *)
       echo "ERROR -- Unknown parameter: $1"; echo; echo "$USAGE"; exit 1
@@ -139,13 +139,14 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
   PATH_PREFIX=$(echo "$PAGE" | jq -r '.path')
   [[ -n "$PATH_PREFIX" && "${PATH_PREFIX: -1}" != "/" ]] && PATH_PREFIX="${PATH_PREFIX}/"
   NUM_CHILDS=$(echo "$PAGE" | jq '.childs | length')
-  TITLE_YAML=$(echo "$PAGE" | jq '.name')
 
   if [[ "$FILE" == "index.html" ]]; then
+    TITLE_YAML=$(echo "$JSON" | jq '.project')
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     CANONICAL_URL="${CANONICAL}/"
   else
+    TITLE_YAML=$(echo "$PAGE" | jq '.name')
     HREF="$FILE"
     if [[ "$NUM_CHILDS" -gt 0 ]]; then
       CONTENT_REL="${PATH_PREFIX}${HREF%.html}/_index.html"