fakestache-ssg

[Archived] A static site generator in Bash 4.
Log | Files | Refs | Submodules | README

commit f9d63a3b38c7cd5aee2d16a39756bfe26e63b6d8
parent 09899912a42583abf981a3abb7ebf71f0bbb457d
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Mon,  7 Nov 2016 11:22:59 -0500

Use mustache to build the feed entries file.

Diffstat:
Mfunctions/create-feed | 27++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/functions/create-feed b/functions/create-feed @@ -2,29 +2,22 @@ # Create the Atom feed from the flat database create_feed () { - while read feed_entry; do - field_date=`echo $feed_entry | cut -d "|" -f 1` - field_datetime=`echo $feed_entry | cut -d "|" -f 2` - field_permalink=`echo $feed_entry | cut -d "|" -f 3` - field_title=`echo $feed_entry | cut -d "|" -f 4` + while read -r feed_entry; do + field_date=$(echo $feed_entry | cut -d "|" -f 1) + field_datetime=$(echo $feed_entry | cut -d "|" -f 2) + field_permalink=$(echo $feed_entry | cut -d "|" -f 3) + field_title=$(echo $feed_entry | cut -d "|" -f 4) + + mo "$TPL_MUSTACHE_PATH/feed/feed-entry.mustache" - echo "<entry>" - echo "<title>$field_title</title>" - echo "<link href=\"$field_permalink\" />" - echo "<updated>$field_date""T$field_datetime</updated>" - echo "<author>" - echo "<name>$SITE_AUTHOR</name>" - echo "<email>$SITE_AUTHOR_EMAIL</email>" - echo "</author>" - echo "</entry>" - done < "$FAKESTACHE_PATH"/"$DB" > feed.atom.xhtml - # This is for the feed + # Build the feed with Pandoc from the `feed.atom.xhtml` file pandoc -t html "$FAKESTACHE_PATH/feed.atom.xhtml" -s \ --template="$TPL_PANDOC_PATH/feed.txt" \ -o "$PUBLICHTML/feed.atom.xml" \ --parse-raw - rm "$FAKESTACHE_PATH/feed.atom.xhtml" + # Then remove it when the feed is created + rm "$FAKESTACHE_PATH/feed.atom.xhtml" }