Got rid of janky build.sh script. Now uses a bunch of janky scripts and a make file - because that is bound to be easier to maintain.
23 lines
648 B
Bash
Executable file
23 lines
648 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
tag="$(echo "$1" | tr ' ' '_' | tr 'A-Z' 'a-z')"
|
|
|
|
if [ "$tag" == "all" ]; then
|
|
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' | sort -r -u |
|
|
cut -d '-' -f 2- | cut -d '.' -f 1
|
|
else
|
|
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' | sort -r -u |
|
|
while read file; do
|
|
tags="$(sed -n '/---/,/---/p' "$file" |
|
|
sed -n '1,/---/p' | sed '/^---$/d' |
|
|
sed '/^$/,$d' |
|
|
yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' |
|
|
tr 'A-Z' 'a-z' | tr ' ' '_'
|
|
)"
|
|
if echo "$tags" | grep -q "$tag"; then
|
|
echo "$file" | cut -d '-' -f 2- | cut -d '.' -f 1
|
|
fi
|
|
done
|
|
|
|
fi
|
|
|