From 9d2f13f1cd65ac1883a562e19515261a332a6707 Mon Sep 17 00:00:00 2001 From: somini Date: Mon, 14 Sep 2020 00:59:20 +0100 Subject: [PATCH 1/3] Support all tags Instead of allowing only a subset of tag names, `slugify` the tag name so that the URL is always valid. This is the same thing done on "jekyll-archives": - https://github.com/jekyll/jekyll-archives/blob/master/lib/jekyll-archives/archive.rb#L132 --- lib/jekyll-feed/generator.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index 7a959199..7a3159ef 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -89,12 +89,9 @@ def generate_feed_by_tag def generate_tag_feed(tags_pool, tags_path) tags_pool.each do |tag| - # allow only tags with basic alphanumeric characters and underscore to keep - # feed path simple. - next if %r![^a-zA-Z0-9_]!.match?(tag) - + tag_slug = Jekyll::Utils.slugify(tag) Jekyll.logger.info "Jekyll Feed:", "Generating feed for posts tagged #{tag}" - path = "#{tags_path}#{tag}.xml" + path = "#{tags_path}#{tag_slug}.xml" next if file_exists?(path) @site.pages << make_page(path, :tags => tag) From 1bb77294d2ea72ccb740b5aa721ef929580c85e3 Mon Sep 17 00:00:00 2001 From: somini Date: Sun, 15 Aug 2021 11:59:38 +0100 Subject: [PATCH 2/3] Mark tag-specific feeds as "tag" collection --- lib/jekyll-feed/generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index 7a3159ef..e0cf001e 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -94,7 +94,7 @@ def generate_tag_feed(tags_pool, tags_path) path = "#{tags_path}#{tag_slug}.xml" next if file_exists?(path) - @site.pages << make_page(path, :tags => tag) + @site.pages << make_page(path, :collection => "tag", :tags => tag) end end From 4fa351acf3be5ddcaccbeb7ddb1649465f51e546 Mon Sep 17 00:00:00 2001 From: somini Date: Fri, 18 Apr 2025 01:57:26 +0100 Subject: [PATCH 3/3] Support all collection and categories Slugify those strings too. --- lib/jekyll-feed/generator.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-feed/generator.rb b/lib/jekyll-feed/generator.rb index e0cf001e..152111c3 100644 --- a/lib/jekyll-feed/generator.rb +++ b/lib/jekyll-feed/generator.rb @@ -47,8 +47,10 @@ def config # WIll return `/feed/collection.xml` for other collections # Will return `/feed/collection/category.xml` for other collection categories def feed_path(collection: "posts", category: nil) - prefix = collection == "posts" ? "/feed" : "/feed/#{collection}" - return "#{prefix}/#{category}.xml" if category + collection_slug = Jekyll::Utils.slugify(collection) + prefix = collection == "posts" ? "/feed" : "/feed/#{collection_slug}" + category_slug = Jekyll::Utils.slugify(category) + return "#{prefix}/#{category_slug}.xml" if category collections.dig(collection, "path") || "#{prefix}.xml" end