fix: remove frontmatter

This commit is contained in:
Dave Kerr
2025-03-31 08:27:42 +01:00
parent 32d95692c6
commit 2140429b95
5 changed files with 44 additions and 81 deletions

View File

@@ -17,9 +17,20 @@ fi
export date="${DATE:-$(date +%F)}"
export version="${VERSION?error: VERSION must be set}"
# Update the input file to an intermedate.
intermediate="${input}.temp"
DATE="${date}" VERSION="${version}" envsubst < "${input}" > "${intermediate}"
cat <<EOF > "${intermediate}"
---
title: "Hacker Laws"
author: "Dave Kerr, github.com/dwmkerr/hacker-laws"
subtitle: "Laws, Theories, Principles, and Patterns that developers will find useful. ${VERSION}, ${DATE}."
version: ${VERSION}
---
EOF
cat "${input}" >> "${intermediate}"
DATE="${date}" VERSION="${version}" envsubst < "${intermediate}" > "${output}"
# Use a single `sed` command to clean up unwanted lines and emojis in one pass.
sed -e '/💻📖.*/d' \
@@ -27,7 +38,7 @@ sed -e '/💻📖.*/d' \
-e '/^\[Translations.*/d' \
-e '/\*.*/d' \
-e '/ \*.*/d' \
-e '/## Translations/,$d' "${intermediate}" > "${output}"
rm "${intermediate}"
-e '/## Translations/,$d' "${output}" > "${intermediate}"
mv "${intermediate}" "${output}"
echo "${output} prepared successfully."