Skip to content

Commit

Permalink
Rename head filter to avoid conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jun 17, 2024
1 parent c9f12d2 commit f711ff7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/virtualTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
<atom:link href="{{ permalink | htmlBaseUrl(metadata.base) }}" rel="self" type="application/rss+xml" />
<description>{{ metadata.subtitle }}</description>
<language>{{ metadata.language or page.lang }}</language>
{%- for post in collections.${collection.name} | reverse | head(${collection.limit}) %}
{%- for post in collections.${collection.name} | reverse | eleventyFeedHead(${collection.limit}) %}
{%- set absolutePostUrl = post.url | htmlBaseUrl(metadata.base) %}
<item>
<title>{{ post.data.title }}</title>
Expand Down Expand Up @@ -46,7 +46,7 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
<email>{{ metadata.author.email }}</email>
{%- endif %}
</author>
{%- for post in collections['${collection.name}'] | reverse | head(${collection.limit}) %}
{%- for post in collections['${collection.name}'] | reverse | eleventyFeedHead(${collection.limit}) %}
{%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %}
<entry>
<title>{{ post.data.title }}</title>
Expand Down Expand Up @@ -75,7 +75,7 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
}
],
"items": [
{%- for post in collections['${collection.name}'] | reverse | head(${collection.limit}) %}
{%- for post in collections['${collection.name}'] | reverse | eleventyFeedHead(${collection.limit}) %}
{%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %}
{
"id": "{{ absolutePostUrl }}",
Expand Down Expand Up @@ -145,12 +145,12 @@ async function eleventyFeedPlugin(eleventyConfig, options = {}) {
};

// Get the first `n` elements of a collection.
eleventyConfig.addFilter('head', function(array, n) {
eleventyConfig.addFilter("eleventyFeedHead", function(array, n) {
if(!n || n === 0) {
return array;
}
if(n < 0) {
throw new Error("`collection.limit` option must be a positive number.");
return array.slice(n);
}
return array.slice(0, n);
});
Expand Down

0 comments on commit f711ff7

Please sign in to comment.