mirror of
https://github.com/ivabus/www
synced 2024-11-10 06:35:16 +03:00
26 lines
740 B
Bash
Executable file
26 lines
740 B
Bash
Executable file
#!/bin/bash
|
|
# cmd: $ ./build-package-pages.sh srcJson targetPath
|
|
# sample: $ .github/build-package-pages.sh src/data/packages.json src/content/'
|
|
|
|
for row in $(jq -r '.[] | @base64' < "$1"); do
|
|
_jq() {
|
|
echo "${row}" | base64 --decode | jq -r "${1}"
|
|
}
|
|
full_name=$(_jq '.full_name' | tr '[:upper:]' '[:lower:]')
|
|
|
|
if [[ "$full_name" == *\/* ]] || [[ "$full_name" == *\\* ]]
|
|
then
|
|
mkdir -p "$2/+$full_name"
|
|
rm -rf "$2/+$full_name"
|
|
fi
|
|
echo $full_name
|
|
touch "$2"/"+$full_name".md
|
|
content="---
|
|
type: page
|
|
title: \"$(_jq '.name')\"
|
|
maintainer: \"$(_jq '.maintainer')\"
|
|
Description: \"$(_jq '.desc' | tr '\"' "'")\"
|
|
layout: \"package-detail\"
|
|
---"
|
|
echo "$content" > "$2"/"+$(_jq '.full_name')".md
|
|
done |