Website/bin/htmlIntro
Jonathan Hodgson 56f95cb9aa Moved to Makefile based build system
Got rid of janky build.sh script. Now uses a bunch of janky scripts and
a make file - because that is bound to be easier to maintain.
2022-06-13 11:02:02 +01:00

25 lines
580 B
Bash
Executable file

#!/usr/bin/env bash
file="$1"
getBlogSlug(){
echo "$1" | sed 's/^content\//\//' | sed 's/.md$/\//' | sed -E 's/[0-9]+-//'
}
info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')"
slug=$(getBlogSlug "$file")
date="$(echo "$info" | yq -r .date)"
title="$(echo "$info" | yq -r .title)"
description="$(echo "$info" | yq -r .description)"
echo "<article>
<h2><a href='$slug'>$title</a></h2>
<div class="article-details">
<div class="date">
$date
</div>
</div>
<p>$description</p>
<p><a href='$slug'>Read More</a></p>
</article>"