Shell Script
FlatCMS で扱っていた過去ブログファイルを変換する。変換に用いたスニペットは以下
cnt=1
cat simpleblog.json| jq -c '.posts[]'| while read -r line
do
echo -E "$line" > "output/blog"$cnt".json"
cnt=$((cnt+1))
done
ls output | while read line
do
TITLE=$(cat output/$line|jq -r '.title')
DESC=$(cat output/$line|jq -r '.description')
DATE=$(gdate --utc --iso-8601=seconds --date @$(cat output/$line|jq -r '.date'))
BODY=$(cat output/$line|jq -r '.body')
FILENAME=$(echo "$TITLE.md"| sed "s/\///g")
echo $FILENAME
touch "conv/$FILENAME"
echo "---" >> "conv/$FILENAME"
echo "title: \"$FILENAME\"" >> "conv/$FILENAME"
echo "date: $DATE" >> "conv/$FILENAME"
echo "description: \"$DESC\"" >> "conv/$FILENAME"
echo "type: post" >> "conv/$FILENAME"
echo "showTableOfContents: true" >> "conv/$FILENAME"
echo "---" >> "conv/$FILENAME"
echo "" >> "conv/$FILENAME"
echo "$BODY" >> "conv/$FILENAME"
done