Skip to content

Commit

Permalink
fix: add support for multi RSS feed
Browse files Browse the repository at this point in the history
- close #588
  • Loading branch information
LouisBarranqueiro committed Dec 15, 2019
1 parent ae0d1cf commit 540336d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var fb_admin_ids = [];
var keywords = '';
var photos = [];
var publisher = '';
var feeds = [];
/**
* Separate fb admin ids
Expand Down Expand Up @@ -109,6 +110,24 @@ var publisher = '';
});
}
})();
// Format RSS/Atom feeds.
(function() {
function getFeedContentType(feedType) {
return feedType === 'atom' ? 'atom' : 'rss';
}
if (!config.feed || !config.feed.path.length) {
return;
}
var feedType = config.feed.type;
var feedPath = config.feed.path;
var feedTypes = typeof feedType === 'string' ? [feedType] : feedType;
var feedPaths = typeof feedPath === 'string' ? [feedPath] : feedPath;
feedPaths.forEach((feedPath, index) => {
feeds.push({type: getFeedContentType(feedTypes[index]), path: feedPath});
})
})()
%>
<head>
<meta charset="UTF-8">
Expand All @@ -122,8 +141,10 @@ var publisher = '';
<% if (theme.favicon) { %>
<link rel="icon" href="<%= resolve_asset_url(theme.image_dir, theme.favicon) %>">
<% } %>
<% if ((config.feed) && (config.feed.path.length)) { %>
<link rel="alternate" type="application/atom+xml" title="RSS" href="<%- url_for(config.feed.path) %>">
<% if (feeds.length) { %>
<% feeds.forEach(function(feed) { %>
<link rel="alternate" type="application/<%= feed.type %>+xml" title="RSS" href="<%- url_for(feed.path) %>">
<% }) %>
<% } %>
<%- json_ld() %>
<%- open_graph({
Expand Down

0 comments on commit 540336d

Please sign in to comment.