From: Kai Moritz Date: Wed, 17 Jun 2026 16:09:02 +0000 (+0000) Subject: Fix three regressions introduced by the previous simplification X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ddcacf90886f31c1ea3053c8533d8d3389ed2c9b;p=maven-thymeleaf-skin Fix three regressions introduced by the previous simplification 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 --- diff --git a/src/main/resources/import-in-astro.sh b/src/main/resources/import-in-astro.sh index 96b4d81..fad7c75 100755 --- a/src/main/resources/import-in-astro.sh +++ b/src/main/resources/import-in-astro.sh @@ -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" diff --git a/src/main/resources/import-in-hugo.sh b/src/main/resources/import-in-hugo.sh index 3ed56a4..1540bb2 100755 --- a/src/main/resources/import-in-hugo.sh +++ b/src/main/resources/import-in-hugo.sh @@ -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"