Skip to content

Instantly share code, notes, and snippets.

@Demindiro
Last active August 15, 2022 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demindiro/d21b210016c4caeb1573399b4fbc8fce to your computer and use it in GitHub Desktop.
Save Demindiro/d21b210016c4caeb1573399b4fbc8fce to your computer and use it in GitHub Desktop.
Simple static site generator. Licensed under the CC0 so do whatever you want.
#!/usr/bin/env bash
for file in `find . -name '*.md'`; do
output=${file::-3}.html
if [[ `date -r "$file" "+%s"` -le `date -r "../$output" "+%s"` ]]
then
echo "Skipping $file"
continue
fi
mkdir -p ../$(dirname $output)
echo Generating $output from $file
cat << EOF > ../$output
<!DOCTYPE html>
`cat head.html`
<body>
`cat navigation.html`
<main>
`pandoc $file`
</main>
<footer>
<span>The content on this page is licensed under the CC BY-ND 4.0</span>
<a style="float:right" href="/md/$file">Source</a>
</footer>
</body>
EOF
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment