#! /bin/bash cd "$(dirname "$BASH_SOURCE")" files_d="$PWD/files" runbooks_d="$HOME/repos/runbooks" find "$runbooks_d" -type f -name "*.md" | while read -r line; do relative="${line#$runbooks_d/}" echo relative=$relative mkdir -p "$files_d"/"${relative%.md}" content="$(cat "$line" | jq -sR)" printf '{ "content": %s, "title": "%s" }' "$content" "${relative##*/}" > "$files_d"/"${relative%.md}"/data.yaml done find "$files_d" -type d | while read -r files_d; do echo asserting "$files_d/data.yaml" if [ ! -f "$files_d"/data.yaml ]; then printf '{"title": "%s"}' "${files_d##*/}" > "$files_d"/data.yaml fi done