diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index db0ae93..6883d57 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -35,6 +35,8 @@ jobs: with: source: ./ destination: ./_site + - name: Minify json files + run: bash jsonMinify.sh - name: Upload artifact uses: actions/upload-pages-artifact@v2 diff --git a/jsonMinify.sh b/jsonMinify.sh new file mode 100755 index 0000000..c053615 --- /dev/null +++ b/jsonMinify.sh @@ -0,0 +1,13 @@ +find ./_site/ \( -iname '*.json' \) -type f -print0 | while IFS= read -r -d $'\0' jsonFile; do + if [[ "$OSTYPE" == "darwin"* ]]; then + if ! command -v gsed &> /dev/null + then + echo "Please install GNU sed as gsed" + else + jq -c . < "$jsonFile" | gsed -z '$ s/\n$//' > "$jsonFile-tempOut" + fi + else + jq -c . < "$jsonFile" | sed -z '$ s/\n$//' > "$jsonFile-tempOut" + fi + mv "$jsonFile-tempOut" "$jsonFile" +done