Skip to content

Commit a36711c

Browse files
committed
Make metadata.author.email optional in virtual templates.
1 parent 38b3a21 commit a36711c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/virtualTemplate.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
4242
<id>{{ metadata.base | addPathPrefixToFullUrl }}</id>
4343
<author>
4444
<name>{{ metadata.author.name }}</name>
45+
{%- if metadata.author.email %}
4546
<email>{{ metadata.author.email }}</email>
47+
{%- endif %}
4648
</author>
4749
{%- for post in collections['${collection.name}'] | reverse | head(${collection.limit}) %}
4850
{%- set absolutePostUrl %}{{ post.url | htmlBaseUrl(metadata.base) }}{% endset %}
@@ -67,8 +69,9 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
6769
"description": "{{ metadata.description }}",
6870
"authors": [
6971
{
70-
"name": "{{ metadata.author.name }}",
71-
"url": "{{ metadata.author.url }}"
72+
"name": "{{ metadata.author.name }}"{% if metadata.author.email %},
73+
"url": "mailto:{{ metadata.author.email }}"
74+
{%- endif %}
7275
}
7376
],
7477
"items": [
@@ -91,18 +94,19 @@ ${stylesheet ? `<?xml-stylesheet href="${stylesheet}" type="text/xsl"?>\n` : ""}
9194
}
9295

9396
async function eleventyFeedPlugin(eleventyConfig, options = {}) {
94-
eleventyConfig.versionCheck(">=3.0.0-alpha.11");
97+
eleventyConfig.versionCheck(pkg["11ty"].compatibility);
9598

96-
// Guaranteed unique
99+
// Guaranteed unique, first add wins
97100
const pluginRss = require("../.eleventy.js");
98101
eleventyConfig.addPlugin(pluginRss, options.rssPluginOptions || {});
99102

100-
// Guaranteed unique
103+
// Guaranteed unique, first add wins
101104
const pluginHtmlBase = await eleventyConfig.resolvePlugin("@11ty/eleventy/html-base-plugin");
102105
eleventyConfig.addPlugin(pluginHtmlBase, options.htmlBasePluginOptions || {});
103106

104107
let slugifyFilter = eleventyConfig.getFilter("slugify");
105108
let inputPathSuffix = options?.metadata?.title ? `-${slugifyFilter(options?.metadata?.title)}` : "";
109+
106110
options = DeepCopy({
107111
// rss and json also supported
108112
type: "atom",
@@ -120,7 +124,7 @@ async function eleventyFeedPlugin(eleventyConfig, options = {}) {
120124
base: "https://example.com/",
121125
author: {
122126
name: "Your Name",
123-
email: "me@example.com"
127+
email: "", // Optional
124128
}
125129
}
126130
}, options);

0 commit comments

Comments
 (0)