aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-feeds-for-categories.rb
diff options
context:
space:
mode:
Diffstat (limited to '_plugins/generate-feeds-for-categories.rb')
-rw-r--r--_plugins/generate-feeds-for-categories.rb30
1 files changed, 27 insertions, 3 deletions
diff --git a/_plugins/generate-feeds-for-categories.rb b/_plugins/generate-feeds-for-categories.rb
index f5cc8db..9958fba 100644
--- a/_plugins/generate-feeds-for-categories.rb
+++ b/_plugins/generate-feeds-for-categories.rb
@@ -1,5 +1,5 @@
module Jekyll
- class FeedsForCategoriesGenerator < Generator
+ class FeedsGenerator < Generator
safe true
def gen_categories_index(site)
@@ -23,7 +23,8 @@ module Jekyll
categories_index
end
- def generate(site)
+ def feeds_by_category(site)
+ feed_pages = []
gen_categories_index(site).each do |collection_name, langs|
langs.each do |lang, categories|
categories.each do |category_name, articles|
@@ -33,10 +34,33 @@ module Jekyll
page.content = <<-EOF
{% include feed.atom entries=site.#{collection_name} kind="#{collection_name}" lang="#{lang}" categories_filter="#{category_name}" %}
EOF
- site.pages << page
+ feed_pages << page
end
end
end
+ feed_pages
+ end
+
+ def global_feeds(site)
+ feed_pages = []
+ langs = site.config['langs']
+ collections = site.config['collections'].keys
+ langs.each do |lang|
+ collections.each do |collection|
+ feed_name = "feed.#{collection}.#{lang}.atom"
+ page = PageWithoutAFile.new(site, site.source, "", feed_name)
+ page.content = <<-EOF
+{% include feed.atom entries=site.#{collection} kind="#{collection}" lang="#{lang}" %}
+ EOF
+ feed_pages << page
+ end
+ end
+ feed_pages
+ end
+
+ def generate(site)
+ site.pages.concat(feeds_by_category(site))
+ site.pages.concat(global_feeds(site))
end
end