diff options
author | EuAndreh <eu@euandre.org> | 2021-10-02 21:43:12 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-10-02 21:43:15 -0300 |
commit | ffbdc7325c7271ab816dc3c1327f6efe67858f1f (patch) | |
tree | 964ab2a10a8dc96b3b28acb7a0d0ca9ef68665b7 /aux/workflow/public.sh | |
parent | Makefile: Generate src/locale/en.sh for translation (diff) | |
download | git-permalink-ffbdc7325c7271ab816dc3c1327f6efe67858f1f.tar.gz git-permalink-ffbdc7325c7271ab816dc3c1327f6efe67858f1f.tar.xz |
aux/workflow/: Add <link rel="alternate" for translated CommonMark pages
Implements #task-43e9d7dd-987a-2f71-629f-28a4cc69be1e.
Diffstat (limited to '')
-rwxr-xr-x | aux/workflow/public.sh | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/aux/workflow/public.sh b/aux/workflow/public.sh index 38613de..2c8c36a 100755 --- a/aux/workflow/public.sh +++ b/aux/workflow/public.sh @@ -1,6 +1,9 @@ #!/bin/sh set -eu +TLD="$(cat aux/tld.txt)" +. aux/lib.sh + PROJECT_UC= while getopts 'n:N:m:o:l:' flag; do case "$flag" in @@ -39,6 +42,23 @@ assert_arg "${OUTDIR:-}" '-o OUTDIR' assert_arg "${LANGS:-}" '-l LANGS' PROJECT_UC="${PROJECT_UC:-$PROJECT}" + +alternates_for() { + ALTERNATES="$(mkstemp)" + lang="$1" + OUTNAME="$2" + for l in $LANGS; do + if [ "$l" = "$lang" ]; then + continue + fi + cat <<EOF >> "$ALTERNATES" +<link rel="alternate" href="https://$TLD/$PROJECT/$l/$OUTNAME" hreflang="$l" /> +EOF + done + echo "$ALTERNATES" +} + + mkdir -p "$OUTDIR" sh aux/workflow/TODOs.sh \ @@ -46,9 +66,13 @@ sh aux/workflow/TODOs.sh \ for lang in $LANGS; do mkdir -p "$OUTDIR/$lang/" - sh aux/workflow/commonmark.sh -N "$PROJECT" -t README -l "$lang" \ + sh aux/workflow/commonmark.sh \ + -N "$PROJECT" -l "$lang" -t README \ + -H "$(alternates_for "$lang" '')" \ < "README.$lang.md" > "$OUTDIR/$lang/index.html" - sh aux/workflow/commonmark.sh -N "$PROJECT" -t CHANGELOG -l "$lang" \ + sh aux/workflow/commonmark.sh \ + -N "$PROJECT" -l "$lang" -t CHANGELOG \ + -H "$(alternates_for "$lang" 'CHANGELOG.html')" \ < "CHANGELOG.$lang.md" > "$OUTDIR/$lang/CHANGELOG.html" ln -fs ../favicon.svg "$OUTDIR/$lang" done |