2022-10-14 05:18:41 +03:00
|
|
|
#!/bin/bash
|
2022-10-14 04:46:45 +03:00
|
|
|
# cmd: $ ./build-package-pages.sh srcJson targetPath
|
2022-11-14 14:50:04 +03:00
|
|
|
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/'
|
2022-10-14 04:46:45 +03:00
|
|
|
|
2022-11-01 23:09:04 +03:00
|
|
|
for row in $(jq -r '.[] | @base64' < "$1"); do
|
2022-10-14 04:46:45 +03:00
|
|
|
_jq() {
|
2022-11-01 23:09:04 +03:00
|
|
|
echo "${row}" | base64 --decode | jq -r "${1}"
|
2022-10-14 04:46:45 +03:00
|
|
|
}
|
2022-12-07 07:55:34 +03:00
|
|
|
full_name=$(_jq '.full_name' | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
|
2022-11-14 14:50:04 +03:00
|
|
|
|
|
|
|
if [[ "$full_name" == *\/* ]] || [[ "$full_name" == *\\* ]]
|
|
|
|
then
|
|
|
|
mkdir -p "$2/+$full_name"
|
2022-12-07 08:07:00 +03:00
|
|
|
# remove last folder
|
2022-11-14 14:50:04 +03:00
|
|
|
rm -rf "$2/+$full_name"
|
|
|
|
fi
|
2022-12-07 08:07:00 +03:00
|
|
|
|
2022-12-07 07:18:33 +03:00
|
|
|
touch "$2"/"+$full_name".md
|
2022-10-14 04:46:45 +03:00
|
|
|
content="---
|
|
|
|
type: page
|
2023-03-24 01:38:50 +03:00
|
|
|
title: \"Install $(_jq '.name')\"
|
2022-11-01 23:09:04 +03:00
|
|
|
maintainer: \"$(_jq '.maintainer')\"
|
2022-10-20 07:46:01 +03:00
|
|
|
Description: \"$(_jq '.desc' | tr '\"' "'")\"
|
2023-03-24 01:11:30 +03:00
|
|
|
og_image: \"$(_jq '.thumb_image_url')\"
|
2022-10-14 04:46:45 +03:00
|
|
|
layout: \"package-detail\"
|
|
|
|
---"
|
2022-12-07 08:07:00 +03:00
|
|
|
echo "$content" > "$2"/"+$full_name".md
|
2023-03-24 01:11:30 +03:00
|
|
|
done
|