Module: Nanoc::Feeds::Helpers::Feeds
Instance Method Summary collapse
- #build_for_article(article, title) ⇒ Object
- #feed(params = {}) ⇒ Object
- #json_feed(params = {}) ⇒ Object
Instance Method Details
#build_for_article(article, title) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/nanoc/feeds/helpers/feeds.rb', line 27 def build_for_article(article, title) { id: "#{config[:base_url]}#{article.identifier.without_exts}", url: url_for(article), title: article[:title] || title, content_text: "#{article.compiled_content}", date_published: "#{article[:created_at].rfc3339}" } end |
#feed(params = {}) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/nanoc/feeds/helpers/feeds.rb', line 7 def feed(params = {}) if @rep.name == :json json_feed(params) else atom_feed(params) end end |
#json_feed(params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nanoc/feeds/helpers/feeds.rb', line 15 def json_feed(params = {}) articles = params[:articles] title = params[:title] || @config[:title] { version: "https://jsonfeed.org/version/1.1", title: title, home_page_url: "#{config[:base_url]}", feed_url: "#{config[:base_url]}/feed.json", items: articles.map { |article| build_for_article(article, title) } }.to_json end |