itsericwoodward-site-v2/src/support/feed.xml.ejs

74 lines
1.9 KiB
Plaintext

<?xml version="1.0" encoding="UTF-8"?>
<%- include('../layouts/functions') -%>
<%
// validator: https://validator.w3.org/feed/#validate_by_input
const { author, copyright, language, tags } = site;
-%>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><%- site.title %></title>
<link href="<%- site.uri %>/" />
<updated><%- (new Date()).toJSON() -%></updated>
<id><%- site.uri %></id>
<author>
<% if (author.name) { -%>
<name><%- author.name %></name>
<% } -%>
<% if (author.email) { -%>
<email><%- author.email %></email>
<% } -%>
<% if (author.site) { -%>
<uri><%- author.site %></uri>
<% } -%>
</author>
<link rel="self" href="<%- site.uri %>/feed.xml" />
<% if (copyright) { -%>
<rights><%= copyright %></rights>
<% } -%>
<% if (author.photo) { -%>
<logo><%= author.photo %></logo>
<% } -%>
<generator>ItsEricWoodward.com</generator>
<%
if (typeof tags === 'string') {
const keywords = tags.split(/\W+/);
for (var i=0; i < keywords.length; i++) {
if (keywords[i]) {
-%>
<category><%= keywords[i] %></category>
<%
}
}
}
-%>
<% if (site && Array.isArray(site.pages)) {
site.pages
.sort((p1, p2) => {
const p1Date = new Date(p1.date_upd || p1.date_pub);
const p2Date = new Date(p2.date_upd || p2.date_pub);
return p2Date - p1Date;
})
.forEach((page) => { -%>
<entry>
<title type="html"><%= page.title %></title>
<id><%- site.uri %><%- page.path %></id>
<link href="<%- site.uri %><%- page.path %>" rel="alternate" />
<updated><%= (new Date(page.date_upd || page.date_pub)).toJSON() %></updated>
<% if (page.description) { -%>
<summary type="html"><%= page.description %></summary>
<% } -%>
</entry>
<% });
} -%>
</feed>