diff options
author | EuAndreh <eu@euandre.org> | 2020-11-14 13:40:08 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2020-11-14 13:51:07 -0300 |
commit | b611e04abd4576e65d2a9d9dd070d09a02d97aab (patch) | |
tree | 61089943b323ab0be6fd493e3fdde632c153afc5 /_plugins | |
parent | Include link to categories feeds on categories pages (diff) | |
download | euandre.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.rb | 30 |
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 |