Skip to content

Commit

Permalink
better/more jq usage
Browse files Browse the repository at this point in the history
  • Loading branch information
traceypooh committed Jul 14, 2024
1 parent 8e79e0a commit 676ebc1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bin/sitemap
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ function rss() { # xxx <description> using snippet??


function comments() {
# this helps with efficiency but could be replaced with a lot of requests at runtime in the browser
(
mkdir -p comments
cd comments
find . -mindepth 1 -type d |cut -b3- |sort -o index.txt
for DIR in $(cat index.txt); do
OUT=$DIR/index.json
echo '[' >| $OUT
for JSON in $(ls $DIR | grep -Ev '^index.json$'); do
cat "$DIR/$JSON" >> $OUT
echo ",\n" >> $OUT
done
echo "\n{}\n]" >> $OUT
rm -f $OUT
jq -rs '. | map(.)' $DIR/*.json \
| jq '.[] | del(.replyThread) | with_entries(if .key == "_id" then .key = "id" else . end)' \
| jq -s 'flatten(1)' \
> $OUT
done
)
}
Expand Down

0 comments on commit 676ebc1

Please sign in to comment.