<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title><%- site.title %></title>
    <link><%- site.uri %></link>
    <description><%- site.description %></description>
    <% if (language) { %>
      <language><%= language %></language>
    <% } %>
    <% if (copyright) { %>
      <copyright><%= copyright %></copyright>
    <% } %>
    <% 
      if (keywords) {
        var keywords = keywords.split(/\W+/);
        for (var i=0; i < keywords.length; i++) {
          if (keywords[i]) {
          %>
            <category><%= keywords[i] %></category>
          <%
          }
        }
      }  
    %>
    <% if (author.email) { %>
      <managingEditor><%= author.email %></managingEditor>
      <webMaster><%= author.email %></webMaster>
    <% } %>
    <% if (image) { %>
      <image><%= image %></image>
    <% } %>
    <generator>HarpJS</generator>
    <atom:link href="<%- site.uri %>/feed.xml" rel="self" type="application/rss+xml" />
    <% 
      for(slug in public._data) {
        var 
          post = public._data[slug],
          now = new Date(),
          then = post.date_pub ? new Date(post.date_pub) : new Date();
        if (post.title && !post.is_draft && then.getTime() <= now.getTime()) {
        %>
          <item>
            <title><%- post.title %></title>
            <description><%= post.description %></description>
            <pubDate><%= then.toUTCString() %></pubDate>
            <link><%- site.uri %>/<%- slug %>.html</link>
            <guid isPermaLink="true"><%- site.uri %>/<%- slug %>.html</guid>
            
          </item>
        <% 
        }
      } 
    %>
  </channel>
</rss>

