blog/scripts/build.sh
mohamad f4a3e2379e
Some checks are pending
Build and Deploy Blog / build (push) Waiting to run
weeee💃
2025-01-26 02:04:29 +01:00

32 lines
871 B
Bash

#!/bin/bash
# Create public directory if not exists
mkdir -p public
# Copy assets
cp -r assets public/
# Process posts
for post in posts/*.md; do
# Get base name
filename=$(basename "$post" .md)
# Convert markdown to HTML
pandoc "$post" \
--template templates/post.html \
--metadata pagetitle="$(head -n 1 "$post" | sed 's/# //')" \
-o "public/${filename}.html"
done
# Generate index page
echo "<!DOCTYPE html>" > public/index.html
echo "<html lang='en'>" >> public/index.html
pandoc templates/index.html >> public/index.html
echo "<ul>" >> public/index.html
for post in posts/*.md; do
title=$(head -n 1 "$post" | sed 's/# //')
filename=$(basename "$post" .md)
echo "<li><a href='${filename}.html'>$title</a></li>" >> public/index.html
done
echo "</ul>" >> public/index.html
echo "</html>" >> public/index.html