Socket
Socket
Sign inDemoInstall

@11ty/eleventy-plugin-rss

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@11ty/eleventy-plugin-rss - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

2

package.json
{
"name": "@11ty/eleventy-plugin-rss",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "A pack of Eleventy plugins for generating an RSS feed using the Nunjucks templating engine.",

@@ -5,0 +5,0 @@ "publishConfig": {

@@ -5,5 +5,3 @@ const pkg = require("../package.json");

function getFeedContent(options) {
let type = options.type;
function getFeedContent(type, { collectionName, limit }) {
// Note: page.lang comes from the i18n plugin: https://www.11ty.dev/docs/plugins/i18n/#page.lang

@@ -21,3 +19,3 @@

<language>{{ metadata.language or page.lang }}</language>
{%- for post in collections.posts | reverse %}
{%- for post in collections.${collectionName} | reverse | head(${limit}) %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.base) %}

@@ -45,3 +43,3 @@ <item>

<link href="{{ metadata.base | addPathPrefixToFullUrl }}" />
<updated>{{ collections['${options.collectionName}'] | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<updated>{{ collections['${collectionName}'] | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>{{ metadata.base | addPathPrefixToFullUrl }}</id>

@@ -52,3 +50,3 @@ <author>

</author>
{%- for post in collections['${options.collectionName}'] | reverse | head(${options.limit}) %}
{%- for post in collections['${collectionName}'] | reverse | head(${limit}) %}
{%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %}

@@ -81,3 +79,3 @@ <entry>

"items": [
{%- for post in collections['${options.collectionName}'] | reverse | head(${options.limit}) %}
{%- for post in collections['${collectionName}'] | reverse | head(${limit}) %}
{%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %}

@@ -100,2 +98,6 @@ {

function getInputPath(type) {
return `virtual:eleventy-plugin-rss:${type}.njk`;
}
async function eleventyFeedPlugin(eleventyConfig, options = {}) {

@@ -112,9 +114,7 @@ eleventyConfig.versionCheck(">=3.0.0-alpha.11");

let type = options.type || "atom";
options = DeepCopy({
collectionName: false, // required
type: "atom",
outputPath: "/feed.xml",
inputPath: `eleventy-plugin-rss_virtual_${type}.njk`,
files: {
"atom": "/feed.xml"
},
limit: 0, // limit number of entries, 0 means no limit

@@ -137,4 +137,3 @@ metadata: {

let feedData = {
permalink: options.outputPath,
let templateData = {
eleventyExcludeFromCollections: true,

@@ -158,3 +157,22 @@ eleventyImport: {

eleventyConfig.addTemplate(options.inputPath, getFeedContent(options), feedData);
for(let type in options.files) {
let files = options.files[type];
let inputPath;
let outputPath;
if(Array.isArray(files) && files.length === 2) {
[inputPath, outputPath] = files;
} else if(typeof files === "string") {
inputPath = getInputPath(type);
outputPath = files;
} else {
throw new Error("Invalid `files` option. Needs an array of length 2 [inputPath, outputPath] or a string `outputPath`");
}
let data = {
permalink: outputPath,
...templateData,
};
eleventyConfig.addTemplate(inputPath, getFeedContent(type, options), data);
}
};

@@ -161,0 +179,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc