Learn how to generate Atom/XML feeds based on tags by using Middleman.
ready do
blog.tags.each do |tag, posts|
proxy "/tags/#{tag}/feed.xml",
"/tag.xml",
locals: { tag: tag, posts: posts },
ignore: true,
layout: false
end
end
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
site_url = "http://blog.oozou.com/"
xml.title "The Oozou Blog — #{tag.capitalize}"
xml.subtitle "We handcraft beautiful Web and Mobile apps"
xml.id URI.join(site_url, tag_path(tag))
xml.link "href" => URI.join(site_url, tag_path(tag))
xml.link "href" => URI.join(site_url, current_page.path), "rel" => "self"
xml.updated(blog.articles.first.date.to_time.iso8601) unless blog.articles.empty?
xml.author { xml.name "Oozou" }
posts.first(10).each do |article|
xml.entry do
xml.title article.title
xml.link "rel" => "alternate", "href" => URI.join(site_url, article.url)
xml.id URI.join(site_url, article.url)
xml.published article.date.to_time.iso8601
xml.updated File.mtime(article.source_file).iso8601
xml.author article.data.author
xml.avatar article.data.avatar
xml.content article.body, "type" => "html"
end
end
end
From us to your inbox weekly.