diff options
Diffstat (limited to 'v2/src/bin/collection-for')
-rwxr-xr-x | v2/src/bin/collection-for | 29 |
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 |