www/.github/build-package-pages.sh

25 lines
701 B
Bash
Raw Normal View History

2022-10-14 05:18:41 +03:00
#!/bin/bash
# cmd: $ ./build-package-pages.sh srcJson targetPath
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/'
2022-11-01 23:09:04 +03:00
for row in $(jq -r '.[] | @base64' < "$1"); do
_jq() {
2022-11-01 23:09:04 +03:00
echo "${row}" | base64 --decode | jq -r "${1}"
}
full_name=$(_jq '.full_name')
if [[ "$full_name" == *\/* ]] || [[ "$full_name" == *\\* ]]
then
mkdir -p "$2/+$full_name"
rm -rf "$2/+$full_name"
fi
touch "$2"/"+$(_jq '.full_name')".md
content="---
type: page
title: \"$(_jq '.name')\"
2022-11-01 23:09:04 +03:00
maintainer: \"$(_jq '.maintainer')\"
Description: \"$(_jq '.desc' | tr '\"' "'")\"
layout: \"package-detail\"
---"
echo "$content" > "$2"/"+$(_jq '.full_name')".md
done