ludoviclefevre/hexo-generator-seo-friendly-sitemap

View on GitHub
views/post-sitemap.ejs

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% include encodeURLAndEscape.ejs %>
<% include root-page.ejs %>
<% data.items.forEach(function(item){ %>
    <url>
        <loc><%- encodeURLAndEscape(data.urljoin(config.url, item.path)) %></loc>
        <lastmod><%= item.updated.toISOString() || item.date.toISOString() %></lastmod>
        <changefreq>weekly</changefreq>
        <priority><%= item.sitemap_priority || (config.sitemap && config.sitemap.post_priority) || 0.6 %></priority>
<% item.photos.forEach(function(photo){ %>
        <image:image>
<% if(photo.indexOf('http')<0) { %>
            <image:loc><%- encodeURLAndEscape(data.urljoin(config.url, photo)) %></image:loc>
<% } else { %>
            <image:loc><%- encodeURLAndEscape(url.resolve(config.url, photo)) %></image:loc>
<% } %>
        </image:image>
<% }) %>
    </url>
<% }) %>
</urlset>
<% include meta %>