Skip to content

Commit

Permalink
Pick link[rel=alternate] for Atom feeds when possible
Browse files Browse the repository at this point in the history
Fixes #34
  • Loading branch information
nt1m committed Oct 13, 2018
1 parent 6ce9689 commit 345156e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shared/feed-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ const FeedParser = {
const feed = {
type: "atom",
title: getTextFromElement("title", channel),
url: getHrefFromElement("link:not([rel=self])", channel),
url: getHrefFromElement("link[rel=alternate]", channel)
|| getHrefFromElement("link:not([rel=self])", channel),
description: getTextFromElement("subtitle", channel),
language: channel.getAttribute("xml:lang"),
updated: getTextFromElement("updated", channel)
|| getTextFromElement("published", channel)
|| getTextFromElement("published", channel)
};

feed.items = [...doc.querySelectorAll("entry")].map(item => {
return {
title: getTextFromElement("title", item),
url: getHrefFromElement("link", item),
url: getHrefFromElement("link[rel=alternate]", item)
|| getHrefFromElement("link", item),
description: getTextFromElement("content", item),
updated: getTextFromElement("updated", item)
|| getTextFromElement("published", item),
|| getTextFromElement("published", item),
id: getTextFromElement("id", item)
};
});
Expand Down

0 comments on commit 345156e

Please sign in to comment.