Commit 8c334ec1 authored by Daniel Shumway's avatar Daniel Shumway

Merge branch 'develop' into 'master'

feat: RSS feed (first pass)

See merge request !32
parents 04601068 e4d56551
Pipeline #28029202 passed with stages
in 1 minute and 15 seconds
......@@ -160,8 +160,79 @@ var extensions = [
}
];
var output = Raise([extensions, './source'], {
output_dir : './public'
/**-----------RSS-----------------------*/
}).then(function (sitemap) {
var fs = require('fs');
var categories = _.reduce(sitemap, function (result, file) {
if (!file.attributes || !file.attributes.category) {
return result;
}
var collection = file.attributes.category;
result[collection] = result[collection] || [];
result[collection].push({
title : file.attributes.doctitle,
path : path.parse(file.attributes.url).dir,
date : new Date(file.attributes.date),
formatted_date : new Date(file.attributes.date).toLocaleDateString('en-US', {
year : 'numeric',
month : 'long',
day : 'numeric'
}),
summary : file.attributes.description
});
return result;
}, {});
//Sort by date so that you can display them in order. Reverse because newest first.
_.each(categories, function (category, key) {
categories[key] = _.reverse(
_.sortBy(category, 'date'));
});
//Manually build template for now.
var content = (function () {
var content = `<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Daniel Shumway's Blog</title>
<link>https://danshumway.com</link>
<description>I build things on the Internet, and I post about them here.</description>
<atom:link href="https://danshumway.com/rss.xml" rel="self" type="application/rss+xml" />
<lastBuildDate>${ (new Date).toUTCString() }</lastBuildDate>`;
_.each(categories['blog'], function (post) {
content += `<item>
<title>${ post.title }</title>
<link>https://danshumway.com/${ post.path }</link>
<guid>https://danshumway.com/${ post.path }</guid>
<description>${ post.summary }</description>
<pubDate>${ post.date.toUTCString() }</pubDate>
</item>`;
});
content += `</channel>
</rss>`;
return content;
}());
return new Promise(function (res, rej) {
fs.writeFile('./public/rss.xml', content, function (err) {
if (err) { rej(); return; }
res();
});
});
}).catch(function (err) {
console.log(err);
});
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Daniel Shumway's Blog</title>
<link>https://danshumway.com</link>
<description>I build things on the Internet, and I post about them here.</description>
<atom:link href="https://danshumway.com/rss.xml" rel="self" type="application/rss+xml" />
<lastBuildDate>Thu, 16 Aug 2018 11:06:01 GMT</lastBuildDate><item>
<title>The Design is the Implementation</title>
<link>https://danshumway.com/blog/design-is-implementation</link>
<guid>https://danshumway.com/blog/design-is-implementation</guid>
<description>In Reset Hard, I eschew tricks and clever programming in favor of direct, honest systems.</description>
<pubDate>Tue, 14 Aug 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Building a Distributed AI Playground</title>
<link>https://danshumway.com/blog/distributed-ai-playground</link>
<guid>https://danshumway.com/blog/distributed-ai-playground</guid>
<description></description>
<pubDate>Thu, 21 Jun 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Chrome Audio is Broken</title>
<link>https://danshumway.com/blog/chrome-autoplay</link>
<guid>https://danshumway.com/blog/chrome-autoplay</guid>
<description>In which we talk about Chrome's new autoplay policy, the backlash, and where things went wrong.</description>
<pubDate>Thu, 24 May 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Announcing Reset Hard</title>
<link>https://danshumway.com/blog/reset-hard-announcement</link>
<guid>https://danshumway.com/blog/reset-hard-announcement</guid>
<description>Reset Hard is a tactical time-traveling puzzle game with co-op and competitive multiplayer.</description>
<pubDate>Mon, 07 May 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Ludum Dare Postmortem</title>
<link>https://danshumway.com/blog/ludum-41-postmortem</link>
<guid>https://danshumway.com/blog/ludum-41-postmortem</guid>
<description>A brief rundown on my project/experiences with Ludum Dare.</description>
<pubDate>Tue, 24 Apr 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Modern AI Techniques Aren't Working</title>
<link>https://danshumway.com/blog/modern-ai-techniques</link>
<guid>https://danshumway.com/blog/modern-ai-techniques</guid>
<description>Neural networks probably aren't the revolution in AI that we're looking for.</description>
<pubDate>Fri, 06 Apr 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Intro to Browser Testing</title>
<link>https://danshumway.com/blog/browser-testing-distilled</link>
<guid>https://danshumway.com/blog/browser-testing-distilled</guid>
<description>An in-depth overview of how to get started with browser testing via Webdriver.</description>
<pubDate>Fri, 23 Mar 2018 04:00:00 GMT</pubDate>
</item><item>
<title>Why I’m Leaving Oracle</title>
<link>https://danshumway.com/blog/leaving-oracle</link>
<guid>https://danshumway.com/blog/leaving-oracle</guid>
<description>I'm leaving Oracle! Here's how I made that decision and what I plan to do next.</description>
<pubDate>Thu, 15 Mar 2018 04:00:00 GMT</pubDate>
</item></channel>
</rss>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment