From 838cc4547ab66746e3c1971a44ecc4c106b6b2c1 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 29 Apr 2026 11:37:05 +0200 Subject: [PATCH] `import-in-hugo.sh` renders _only_ current _or_ archived * The artifact-id and the version of the project are _always_ added to the specified base-path. * If a *current* version is copied the version is dropped from the path that is added as `url` to front-matter. * If a *archived* version is copied, the path of the current version is added as `params.canonical` to front-matter. --- src/main/resources/import-in-hugo.sh | 111 ++++++++++++++++----------- 1 file changed, 66 insertions(+), 45 deletions(-) mode change 100755 => 100644 src/main/resources/import-in-hugo.sh diff --git a/src/main/resources/import-in-hugo.sh b/src/main/resources/import-in-hugo.sh old mode 100755 new mode 100644 index ee63d30..80c14a2 --- a/src/main/resources/import-in-hugo.sh +++ b/src/main/resources/import-in-hugo.sh @@ -3,40 +3,43 @@ set -euo pipefail if [ $# -lt 1 ] then - echo "Usage: $0 [ --current []] | --archived ] [--canonical ]" + echo "Usage: $0 [--base ] [ [ --current []] | [--archived []] ]" echo - echo "--current : [DEFAULT] specifies the path inside the hugo-project" - echo " if the path is omitted, the artifact-id is used as path" - echo "--archived : specifies the base-path for an archived version" - echo " the artifact-id and the version are added to the path" - echo "--canonical: specifies the path for canonical links in front-matter" + echo "--base : Specifies the base-path for the rendered site." + echo " If not specifed, the site is rendered as a root section." + echo " The artifact-id and the version are always added to the path." + echo "--current : [DEFAULT]" + echo " Adds "url: //" to front-matter." + echo " If "" is not specified, "//" is used." + echo " Only one of "--current" and "--archived" can be used!" + echo "--archived : Adds "params.canonical=//" to front-matter." + echo " If "" is not specified, "//" is used." + echo " Only one of "--current" and "--archived" can be used!" exit 1 fi SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + HUGO_ROOT="${1%%/}" shift -CANONICAL_PATH="" -CURRENT=1 -CANONICAL=0 + +CURRENT=0 +ARCHIVED=0 +CANONICAL="" command -v jq >/dev/null 2>&1 || { echo "ERROR -- jq is required"; exit 1; } JSON=$(sed -n '/