4 ms·
Here is my composable blog with cURL and awk #!/bin/sh process() { output="${1%.*}".html # Convert markdown to html and save curl \ -sS \ -u "
by malkosta 5y ago
Here is my composable blog with cURL and awk
#!/bin/sh
process() {
output="${1%.*}".html
# Convert markdown to html and save
curl \
-sS \
-u "${GITHUB_USERNAME}:${GITHUB_TOKEN}" \
-X POST \
-H "Content-Type: text/plain" -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/markdown/raw \
--data "$(cat $1)" > $output
# Apply layout and save
html=$(awk 'NR==FNR { a[n++]=$0; next } /{{ content }}/ { for (i=0;i<n;++i) print a[i]; next } 1' $output layout.html)
printf "%s" "$html" > "$output"
echo "Processed ${output}"
}
for file in *.md; do process "$file" & done
wait