Bereinigt von Pilot-Spezifika (echte Inhalte, Erzbistum-Hamburg-Bezuege, Domain-Werte) - install.env und hugo.toml [params] mit generischen Platzhaltern. docs/ komplett entfernt: Konzept, Manifest, Installations- anleitungen leben jetzt auf der Projekt-Website statt redundant im Repo, README verweist dorthin. Decap-CMS-Version von einer floatenden ^3.0.0 auf ein festes 3.15.1 gepinnt.
63 lines
2.7 KiB
Bash
Executable File
63 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Generates hugo/data/methoden.json and hugo/data/varianten.json: creation
|
|
# and last-modified date per method/variant, determined from the git
|
|
# history of _content/.
|
|
#
|
|
# Hugo's enableGitInfo/.GitInfo only looks for git history in the repo that
|
|
# contains the Hugo page root (ableger_demo/ableger) - but _content/ is a
|
|
# separate git repo (ableger_demo/ableger_methoden) mounted via
|
|
# module.mounts and is not recognized there (.GitInfo stays nil, no error,
|
|
# just silently empty). This has affected "last modified" ever since the
|
|
# repo split, unnoticed, because Hugo doesn't warn about it.
|
|
# For "created" there would be no Hugo-native equivalent anyway, see
|
|
# https://github.com/gohugoio/hugo/issues/11810 (open).
|
|
#
|
|
# So both dates are read here uniformly from git history ourselves, instead
|
|
# of relying on .GitInfo. Recomputed fresh on every sync rather than
|
|
# maintained (see sync-methoden.sh, which calls this script automatically) -
|
|
# no manual date field, git stays the single source of truth.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
CONTENT_REPO="$ROOT/_content"
|
|
|
|
dates_for_path() {
|
|
local relpath="$1"
|
|
local history erstellt geaendert
|
|
# One "git log --follow" call instead of two: with the full (not -1)
|
|
# history for this path, the first line (newest) is "geaendert" and the
|
|
# last line (oldest, following through renames) is "erstellt" - no need
|
|
# for a second, separately filtered/unfollowed call to get either.
|
|
history="$(git -C "$CONTENT_REPO" log --follow --format=%aI -- "$relpath")"
|
|
geaendert="$(echo "$history" | head -1)"
|
|
erstellt="$(echo "$history" | tail -1)"
|
|
[ -n "$erstellt" ] && [ -n "$geaendert" ] || return 1
|
|
jq -n --arg erstellt "$erstellt" --arg geaendert "$geaendert" '{erstellt: $erstellt, geaendert: $geaendert}'
|
|
}
|
|
|
|
# Both methods and variants are one folder per entry with content in
|
|
# index.md (Hugo page bundle) - variants ever since attachments moved from
|
|
# the method to the respective variant, see admin/config.template.yml.
|
|
generate_bundle_dates() {
|
|
local name="$1"
|
|
local dir="$CONTENT_REPO/$name"
|
|
local out="$ROOT/hugo/data/$name.json"
|
|
mkdir -p "$(dirname "$out")"
|
|
local entries="{}"
|
|
if [ -d "$dir" ]; then
|
|
for entry_dir in "$dir"/*/; do
|
|
local slug
|
|
slug="$(basename "$entry_dir")"
|
|
[ -f "$entry_dir/index.md" ] || continue
|
|
local dates
|
|
dates="$(dates_for_path "$name/$slug/index.md")" || continue
|
|
entries="$(echo "$entries" | jq --arg slug "$slug" --argjson dates "$dates" '. + {($slug): $dates}')"
|
|
done
|
|
fi
|
|
echo "$entries" > "$out"
|
|
echo "$name.json aktualisiert: $(echo "$entries" | jq 'length') Einträge"
|
|
}
|
|
|
|
generate_bundle_dates "methoden"
|
|
generate_bundle_dates "varianten"
|