fakestache-ssg

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

create-feed (850B)


      1 #!/bin/bash
      2 
      3 # Create the Atom feed from the flat database
      4 create_feed () {
      5     while read -r feed_entry; do
      6         field_date=$(echo $feed_entry | cut -d "|" -f 1)
      7         field_datetime=$(echo $feed_entry | cut -d "|" -f 2)
      8         field_permalink=$(echo $feed_entry | cut -d "|" -f 3)
      9         field_title=$(echo $feed_entry | cut -d "|" -f 4)
     10         field_id=$(echo $feed_entry | cut -d "|" -f 5)
     11 
     12         mo "$TPL_MUSTACHE_PATH/feed/feed-entry.mustache"
     13 
     14     done < "$FAKESTACHE_PATH"/"$DB" > feed.atom.xhtml
     15 
     16     # Build the feed with Pandoc from the `feed.atom.xhtml` file
     17     pandoc -t html "$FAKESTACHE_PATH/feed.atom.xhtml" -s \
     18            --template="$TPL_PANDOC_PATH/feed.txt" \
     19            -o "$PUBLICHTML/feed.atom.xml" \
     20            --parse-raw
     21 
     22     # Then remove it when the feed is created
     23     rm "$FAKESTACHE_PATH/feed.atom.xhtml"
     24 }