aboutsummaryrefslogtreecommitdiff
path: root/_plugins
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-11-14 13:40:08 -0300
committerEuAndreh <eu@euandre.org>2020-11-14 13:51:07 -0300
commitb611e04abd4576e65d2a9d9dd070d09a02d97aab (patch)
tree61089943b323ab0be6fd493e3fdde632c153afc5 /_plugins
parentInclude link to categories feeds on categories pages (diff)
downloadeuandre.org-b611e04abd4576e65d2a9d9dd070d09a02d97aab.tar.gz
euandre.org-b611e04abd4576e65d2a9d9dd070d09a02d97aab.tar.xz
Generate feed files for all collections and languages
Diffstat (limited to '')
-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