Skip to content

Instantly share code, notes, and snippets.

@elfacht
Created January 5, 2022 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elfacht/afa2eb68faa3dfa0c55a7d661c55e8ba to your computer and use it in GitHub Desktop.
Save elfacht/afa2eb68faa3dfa0c55a7d661c55e8ba to your computer and use it in GitHub Desktop.
RSS Feed in Haml
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
site_url = "http://blog.url.com/"
xml.title "Blog Name"
xml.subtitle "Blog subtitle"
xml.id URI.join(site_url, blog.options.prefix.to_s)
xml.link "href" => URI.join(site_url, blog.options.prefix.to_s)
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 "Blog Author" }
blog.articles[0..5].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 { xml.name "Article Author" }
# xml.summary article.summary, "type" => "html"
xml.content article.body, "type" => "html"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment