klank-docs/get_events.sh

31 lines
620 B
Bash
Raw Permalink Normal View History

2024-11-12 13:11:02 +00:00
#!/usr/bin/env bash
DIRECTORY=events
if [ ! -d "$DIRECTORY" ]; then
mkdir $DIRECTORY
fi
echo $(curl -s "https://calendar.klank.school/api/events") | jq -c '.[]' | while read -r item; do
slug=$(echo "$item" | jq -r '.slug')
echo $item
export TITLE=$(echo "$item" | jq -r '.title')
export START_DATETIME=$(echo "$item" | jq -r '.start_datetime')
export END_DATETIME=$(echo "$item" | jq -r '.end_datetime')
filename="events/${slug}.md"
if test -f "$filename"; then
rm -f -- $filename
fi
mo templates/event.md >> $filename
echo "Created a new event markdown file for " $filename
done