Tutorial: 11ty Nekoweb rss feed


This WILL be edited in post for clarity, because I'm trying to balance comprehensivity with speed.
If you don't use 11ty, I can still give a decent explanation of how to make an rss feed manually, that is up to nekoweb's required spec, but I wouldn't in any case suggest doing that.

Also, this is how I personally use the plugin, with manual templates, so best of luck with virtual templates.
Also also, I'm running Eleventy 2.0.1 and eleventy-plugin-rss 1.2.0.

(heavy credit to moosyu ahaha. someone threw me their code and i basically just added some things and made all the variables to suit me)

Prerequisites

Template

Include this in your eleventy.js "module.exports = function (eleventyConfig)"

eleventyConfig.addFilter("excerpt", (post) => {
    const content = post.replace(/(<([^>]+)>)/gi, "");
    return content.substr(0, content.lastIndexOf(" ", 200)) + "...";
  });

Place this in a file with the extension .njk located anywhere convenient (i have mine in a folder labled rss in my src directory)

---json
{
  "permalink": "allblogs.xml", <!-- Name of the output file -->
  "eleventyExcludeFromCollections": true,
  "metadata": { <!-- Self explanatory metadata, set this to whatever you desire
  (note, this is for the FEED, not your site hehe) -->
    "title": "FEEDTITLE", 
    "description": "FEEDDESCRIPTION",
    "language": "en-US",
    "url": "URL-TO-YOUR-SITE",
  }
}
---

<rss version="2.0">
<channel>
  <title>{{ metadata.title }}</title>
  <description>{{ metadata.description }}</description>
  <link>{{ metadata.url }}</link>
  {%- for post in collections.COLLECTIONNAME | reverse %}
    {%- set absolutePostUrl = post.url | absoluteUrl(metadata.url) %}
    <item>
    <title>{{ post.data.title }}</title>
    <description>{{ post.content | excerpt }}</description>
    <link>{{ absolutePostUrl }}</link>
    <guid>{{ post.data.title | slugify }}</guid>
    <pubDate>{{ post.date.toUTCString() }}</pubDate>
    <author>{{ metadata.author.email }} ({{ metadata.author.name }})</author>
    <source url="{{ permalink | absoluteUrl(metadata.url) }}">{{ metadata.title }}</source>
    </item>
  {%- endfor %}
</channel>

This isnt just drop in, please edit the top metadata section, aswell as the variable "COLLECTIONNAME" in

{%- set absolutePostUrl = post.url | absoluteUrl(metadata.url) %}

Guid's

For note, guid's must be fully unique. Here they are set as the slugified post title (e.g. "tutorial-11ty-nekoweb-rss-feed"). The literal only problem with this, is that you cant name a post the same thing twice. Just don't do that and you'll be fine.

Alongside that topic, if you'd prefer your guid's to be full urls to your blogpost, change it to

<guid isPermaLink="true">{{ absolutePostUrl }}</guid>

Manually entering posts

why :(
Anyways, you'd just need to follow the same template, and copy and paste the <item> each time you want to make a new post.

Aswell, to follow the rss spec, you would need to format dates in the RFC 822 date format (something like "Fri, 20 Sep 2024 00:00:00 GMT")

(removed <source> from this as its fiddly and not fully necessary)

<rss version="2.0">
<channel>
  <title>XXXX</title>
  <description>XXXX</description>
  <link>LINKTOYOURWEBSITE</link>
  
  <item>
    <title>POSTTITLE</title>
    <description>POSTCONTENT/DESCRIPTION</description>
    <link>POSTLINK (use the full url)</link>
    <guid>UNIQUE ID</guid>
    <pubDate>PUBLISHDATE</pubDate>
  </item>

</channel>

generally you want this to act as a small preface to your article, and have it link over to the full content on your website. be sure to actually link it to your website when all is said and done.

After finishing either of these you just upload/save your feed to your site, and direct nekoweb to where its located