6 ms·
The thing I've never figured out with my Pandoc-generated static sites is how to generate RSS feeds from Markdown frontmatter metadata.
by freosam 9y ago
The thing I've never figured out with my Pandoc-generated static sites is how to generate RSS feeds from Markdown frontmatter metadata.
- ht_th 9y agoFor these type of task, pandocomatic supports preprocessors, postprocessors, filters, setup scripts, and cleanup scripts in its templates. For your specific issue, and this is a general pandoc solution, filters with side effects could work. For example, you can write a filter that would extract and inspect the metadata and writes it to to an RSS XML file. In Paru¹, the Ruby wrapper and interface to pandoc, a very naive solution could look like: #!/usr/bin/env ruby require "paru/filter" require "rss" RSS_FILE = "my-rss-file.rss" title = "No title" date = Time.now.to_s # Collect metadata information while filtering a document with pandoc Paru::Filter.run do title = metadata["title"] if metadata.has_key? "title" date = metadata["date"] if metadata.has_key? "date" end # Create new Atom item new = RSS::Maker.make("atom") do |maker| maker.channel.author = maker.channel.about = maker.channel.title = "" maker.channel.updated = Time.now.to_s maker.items.new_item do |item| item.title = title item.updated = date item.link = "Some link" end end # Add new item to existing Atom RSS feed rss = RSS::Parser.parse(File.read(RSS_FILE), false) rss.items.concat new.items File.write(RSS_FILE, rss) (My apologies for the bad code, this is my first attempt at working with RSS/Atom) ¹ https://heerdebeer.org/Software/markdown/paru/#writing-and-using-pandoc-filters-with-paru https://heerdebeer.org/Software/markdown/paru/#writing-and-u...