]> juplo.de Git - maven-thymeleaf-skin/commitdiff
Append version to entry-page heading in --archived mode
authorKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 16 Oct 2026 07:54:51 +0000 (07:54 +0000)
committerKai Moritz <kai.milan.moritz@googlemail.com>
Fri, 16 Oct 2026 07:54:51 +0000 (07:54 +0000)
When a site is imported with --archived, both the YAML title in the
frontmatter and the first <h1> in the HTML body of the index page now
include the version number in parentheses, e.g. "My Project (1.2.0)".
This makes it immediately clear to visitors (and in browser titles /
breadcrumbs) which version they are viewing.

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 876d719f4597140debce4cc3ba73b8bc1744cbd2..e2c94c29bc9ba46f9715e04dbdc1812e59c378fa 100755 (executable)
@@ -160,7 +160,11 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
   NUM_CHILDS=$(echo "$PAGE" | jq '.childs | length')
 
   if [[ "$FILE" == "index.html" ]]; then
-    TITLE_YAML=$(echo "$JSON" | jq '.project')
+    if [[ "$ARCHIVED" -eq 1 ]]; then
+      TITLE_YAML=$(echo "$JSON" | jq --arg v " ($VERSION)" '.project + $v')
+    else
+      TITLE_YAML=$(echo "$JSON" | jq '.project')
+    fi
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     ROUTING_FILE="index.astro"
@@ -203,6 +207,10 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
       "$CONTENT_TARGET"
   done
 
+  if [[ "$FILE" == "index.html" && "$ARCHIVED" -eq 1 ]]; then
+    sed -i "0,/<\/h1>/s|</h1>| ($VERSION)</h1>|" "$CONTENT_TARGET"
+  fi
+
   echo "Content:  $CONTENT_TARGET"
 
   ROUTING_TARGET="$PAGES_BASE/$ROUTING_FILE"
index 7b998de69f691657bcee9a581401e15b1f2d6bee..77aa05d10f98e36626f3befb8ad68fbe5cb0e058 100755 (executable)
@@ -141,7 +141,11 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
   NUM_CHILDS=$(echo "$PAGE" | jq '.childs | length')
 
   if [[ "$FILE" == "index.html" ]]; then
-    TITLE_YAML=$(echo "$JSON" | jq '.project')
+    if [[ "$ARCHIVED" -eq 1 ]]; then
+      TITLE_YAML=$(echo "$JSON" | jq --arg v " ($VERSION)" '.project + $v')
+    else
+      TITLE_YAML=$(echo "$JSON" | jq '.project')
+    fi
     CONTENT_REL="_index.html"
     PAGE_URL="${URL_BASE}/"
     CANONICAL_URL="${CANONICAL}/"
@@ -178,6 +182,10 @@ for SOURCE in $(find "$SCRIPT_DIR" -maxdepth 1 -mindepth 1 -type f -name '*.html
           's#<pre\b[^>]*>(.*?)</pre>#"{{< highlight guess >}}\n".decode_entities($1)."\n{{< /highlight >}}"#gse'
   } > "$TARGET"
 
+  if [[ "$FILE" == "index.html" && "$ARCHIVED" -eq 1 ]]; then
+    sed -i "0,/<\/h1>/s|</h1>| ($VERSION)</h1>|" "$TARGET"
+  fi
+
   echo "Content:  $TARGET"
 done