From ce483fb126d89be56be117d6290705242c7b262c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Fe=CC=81vrier?= Date: Mon, 12 Apr 2021 15:36:26 +0200 Subject: [PATCH 1/2] Add support custom title for collections --- lib/jekyll-feed/feed.xml | 2 +- lib/jekyll-feed/generator.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jekyll-feed/feed.xml b/lib/jekyll-feed/feed.xml index 9068836f..38046994 100644 --- a/lib/jekyll-feed/feed.xml +++ b/lib/jekyll-feed/feed.xml @@ -11,7 +11,7 @@ {% assign title = site.title | default: site.name %} {% if page.collection != "posts" %} - {% assign collection = page.collection | capitalize %} + {% assign collection = page.title | default: page.collection | capitalize %} {% assign title = title | append: " | " | append: collection %} {% endif %} {% if page.category %} diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index 7a959199..e2085142 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -18,7 +18,7 @@ def generate(site) path = feed_path(:collection => name, :category => category) next if file_exists?(path) - @site.pages << make_page(path, :collection => name, :category => category) + @site.pages << make_page(path, :title => meta["title"], :collection => name, :category => category) end end generate_feed_by_tag if config["tags"] && !@site.tags.empty? @@ -117,13 +117,14 @@ def file_exists?(file_path) # Generates contents for a file - def make_page(file_path, collection: "posts", category: nil, tags: nil) + def make_page(file_path, title: nil, collection: "posts", category: nil, tags: nil) PageWithoutAFile.new(@site, __dir__, "", file_path).tap do |file| file.content = feed_template file.data.merge!( "layout" => nil, "sitemap" => false, "xsl" => file_exists?("feed.xslt.xml"), + "title" => title, "collection" => collection, "category" => category, "tags" => tags From 846c98fc2b5cb9e08728ac2d6b47128612731c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Fe=CC=81vrier?= Date: Mon, 12 Apr 2021 16:47:20 +0200 Subject: [PATCH 2/2] Add support for posts collection disabling --- lib/jekyll-feed/generator.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index e2085142..aa229829 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -67,7 +67,10 @@ def collections {} end - @collections = normalize_posts_meta(@collections) + if config["posts"] != false + @collections = normalize_posts_meta(@collections) + end + @collections.each_value do |meta| meta["categories"] = (meta["categories"] || []).to_set end