<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title><%= config.title %><%= tag ? ` • Posts by "${tag}" tag` : '' %><%= category ? ` • Posts by "${category}" category` : '' %></title>
        <link><%= config.url %></link>
        <description><%= config.description %></description>
        <language><%= config.language %></language>
        <pubDate><%= moment(lastBuildDate).locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ') %></pubDate>
        <lastBuildDate><%= moment(lastBuildDate).locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ') %></lastBuildDate>
        <%_ for (const { name } of (tags || [])) { _%>
        <category><%= name %></category>
        <%_ } _%>
        <%_ for (const post of posts) { _%>
        <item>
            <guid isPermalink="true"><%= post.permalink %></guid>
            <title><%= post.title %></title>
            <link><%= post.permalink %></link>
            <%_ for (const tag of (post.tags ? post.tags.toArray() : [])) { _%>
            <category><%= tag.name %></category>
            <%_ } _%>
            <pubDate><%= moment(post.date).locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ') %></pubDate>
            <description><![CDATA[ <%= post.content %> ]]></description>
        </item>
        <%_ } _%>
    </channel>
</rss>
