jekyll / jekyll-feed

:memo: A Jekyll plugin to generate an Atom (RSS-like) feed of your Jekyll posts
MIT License
827 stars 201 forks source link

Custom feed for categories doesn't work if it contains åäö #356

Closed Hund closed 2 years ago

Hund commented 2 years ago

I just tried adding custom feeds for a few catergories to one of my websites. One of this categories is "Träffar" (Meetups).

It does generate a feed, but it doesn't contain any posts.

I'm running Jekyll 4.2.1 with jekyll-feed 0.15.1.

ashmaroli commented 2 years ago

Hi, Could you provide the exact config settings and steps to help me try reproducing this with a bare-bones site?

Hund commented 2 years ago

Sure! The relevant part of my config:

feed:
  categories:
    - Träffar

The category is named "Träffar". The feed url is:

http://localhost:4000/feed/Tr%C3%A4ffar.xml

Or:

http://localhost:4000/feed/Träffar.xml

I'm honestly not sure. It's shown as "Träffar" in the adressbar, but when I copy the url it turns into "Tr%C3%A4ffar".

The feed looks like this for me:

<feed xmlns="http://www.w3.org/2005/Atom">
<generator uri="https://jekyllrb.com/" version="4.2.1">Jekyll</generator>
<link href="http://localhost:4000/feed/Tr%C3%A4ffar.xml" rel="self" type="application/atom+xml"/>
<link href="http://localhost:4000/" rel="alternate" type="text/html"/>
<updated>2021-12-17T17:44:45+01:00</updated>
<id>http://localhost:4000/feed/Tr%C3%A4ffar.xml</id>
<title type="html">Linuxkompis | Träffar</title>
<subtitle>En vänlig Linux-gemenskap för alla!</subtitle>
</feed>
ashmaroli commented 2 years ago

Okay. I was able to reproduce this. The reason behind this is that the feed template doesn't take categories into consideration: https://github.com/jekyll/jekyll-feed/blob/6bc0f83df76dcf28e32ab467ee98caa1719eb4d8/lib/jekyll-feed/feed.xml#L48

The fix is very simple:

- {% assign posts = posts | where: "category", page.category %}
+ {% assign posts = posts | where: "categories", page.category %}

@Hund Are you willing to submit a pull request to patch this..?

Hund commented 2 years ago

Okay. I was able to reproduce this. The reason behind this is that the feed template doesn't take categories into consideration:

https://github.com/jekyll/jekyll-feed/blob/6bc0f83df76dcf28e32ab467ee98caa1719eb4d8/lib/jekyll-feed/feed.xml#L48

The fix is very simple:

- {% assign posts = posts | where: "category", page.category %}
+ {% assign posts = posts | where: "categories", page.category %}

@Hund Are you willing to submit a pull request to patch this..?

Great!

Me? Where? And what exactly should I do?

ashmaroli commented 2 years ago

Me? Where? And what exactly should I do?

Sorry. I didn't mean to get you tensed / confused.. My bad.

I'll do the needful myself. Thanks for reporting.

Hund commented 2 years ago

Me? Where? And what exactly should I do?

Sorry. I didn't mean to get you tensed / confused.. My bad.

I'll do the needful myself. Thanks for reporting.

Thank you! I appreciate it. :)

Hund commented 2 years ago

I'm not sure why, but my extra feeds doesn't update anymore. If I add any posts, they don't show up in the extra feed like they should.

parkr commented 2 years ago

Do you have a link to your site's source, or do you have a sample where you can reproduce the effect? This change doesn't seem like it would affect whether new posts would be added.

Hund commented 2 years ago

Do you have a link to your site's source, or do you have a sample where you can reproduce the effect? This change doesn't seem like it would affect whether new posts would be added.

The issue is probably me. Feel free to have a look at it. :)

Linuxkompis_.zip