Published
Edited
Mar 18, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tableRows = data
.map(parse)
.reduce(reduceDocToRow, [])
.flat()
.filter(omit)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
reduceDocToRow = (acc, doc) => {
// grab the group title
const group = doc
.querySelector("title")
.innerHTML.replace(/^.+tagged as (\S+) from Inoreader.+$/, "$1");

// grab the entries from the document
const entries = Array.from(doc.querySelectorAll('outline outline')).map(c =>
Object.fromEntries(
Array.from(c.attributes).map(node => [node.name, node.value])
)
);

return acc.concat(
entries.map(({ title, htmlUrl, text, xmlUrl, ...e }) => ({
title,
// grab descriptions
description: Object.entries(descriptions.htmlUrl).find(([k,v]) => htmlUrl.includes(k))?.[1] || "",
group,
type: types.find(t => xmlUrl.includes(t.term))?.type || e.type, // fallback to RSS

// set cadence by group ID
cadence: descriptions.group[group],
htmlUrl,
text,
xmlUrl
}))
);
}
Insert cell
Insert cell
Insert cell
opmlTemplate = entries => {
const entriesByGroup = d3.group(entries, e => e.group);
return `<opml version="1.0">
<head>
<title>Custom feed from Spencer's RSS feeds</title>
</head>
<body>
${Array.from(
entriesByGroup,
([key, values]) =>
` <outline text="${key}" title="${key}">
${values.map(outlineTemplate).join("\n ")}
</outline>`
).join("\n")}
</body>
</opml>`;
}
Insert cell
outlineTemplate = ({ text, title, xmlUrl, htmlUrl }) =>
`<outline text="${text}" title="${title}" type="rss" xmlUrl="${xmlUrl}" htmlUrl="${htmlUrl}"/>`
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more