mvp and poc it works with our volume of runbooks inc search

This commit is contained in:
Bel LaPointe
2022-02-09 17:03:26 -07:00
parent 7ee04bbe8e
commit f05cff70b9
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#! /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