aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin/collection-for
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-08 16:20:00 -0300
committerEuAndreh <eu@euandre.org>2023-04-08 21:18:22 -0300
commit6c2cbb02ac4b16ee7b4c37de50403ce604868ec0 (patch)
treeffb2fb30a741a04f89474f64a2e01df3d891cd12 /v2/src/bin/collection-for
parentv2: src/lib/: Unmark things as executable (diff)
downloadeuandre.org-6c2cbb02ac4b16ee7b4c37de50403ce604868ec0.tar.gz
euandre.org-6c2cbb02ac4b16ee7b4c37de50403ce604868ec0.tar.xz
v2: i18n of the collection name, "article" collection in root
Diffstat (limited to 'v2/src/bin/collection-for')
-rwxr-xr-xv2/src/bin/collection-for29
1 files changed, 16 insertions, 13 deletions
diff --git a/v2/src/bin/collection-for b/v2/src/bin/collection-for
index b3fc211..87f1204 100755
--- a/v2/src/bin/collection-for
+++ b/v2/src/bin/collection-for
@@ -24,10 +24,10 @@ help() {
Examples:
- Get "tils" for "src/en/tils/some-pt.md":
+ Get "til" for "src/en/til/some-pt.md":
- $ collection-for src/en/tils/some-pt.md
- tils
+ $ collection-for src/en/til/some-pt.md
+ til
EOF
}
@@ -69,15 +69,18 @@ FILE="${1:-}"
eval "$(assert_arg "$FILE" 'FILE')"
-# echo "${FILE#"$CONTENT_PREFIX"/}" | cut -d/ -f1
-# echo "${FILE#"$CONTENT_PREFIX"/}" | awk '{
- # awk -F/ '$3 && $0=$2 { print; next } $0'
-
-ATTEMPT="$(echo "${FILE#"$CONTENT_PREFIX"/}" | cut -d/ -f2-)"
-
-if [ "$ATTEMPT" = 'index.html' ]; then
- echo articles
+lang="$(lang-for "$FILE")"
+DIR="$(dirname "$FILE")"
+if [ "$DIR" = "$CONTENT_PREFIX/$lang" ]; then
+ echo
else
- NAME="$(echo "$ATTEMPT" | cut -d/ -f1)"
- collections | grep "$NAME"
+ NAME="$(basename "$DIR")"
+ NTH="$(
+ collections |
+ xargs -I% coll2path "$lang" % |
+ awk '{ print NR, substr($0, 1, length($0) - 1) }' |
+ grep " $NAME$" |
+ cut -d' ' -f1
+ )"
+ collections | awk -vNTH="$NTH" 'NR == NTH'
fi