mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 14:57:28 +00:00
Add feed discovery plugin
This commit is contained in:
parent
e47616bf9d
commit
5cfeea6b57
37 changed files with 2432 additions and 5 deletions
26
plugins/feed-discovery/src/output/atom.ts
Normal file
26
plugins/feed-discovery/src/output/atom.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import type { FeedDiscoveryResponse } from "../types.js";
|
||||
import { escapeXml } from "./opml.js";
|
||||
|
||||
export function renderAtom(response: FeedDiscoveryResponse) {
|
||||
const updated = new Date().toISOString();
|
||||
const entries = response.results
|
||||
.map((result) => {
|
||||
const id = result.canonicalFeedUrl ?? result.feedUrl;
|
||||
return ` <entry>
|
||||
<id>${escapeXml(id)}</id>
|
||||
<title>${escapeXml(result.title)}</title>
|
||||
<link href="${escapeXml(result.homepageUrl ?? result.feedUrl)}" />
|
||||
<updated>${escapeXml(result.lastPublishedAt ?? updated)}</updated>
|
||||
<summary>${escapeXml(result.description ?? `Discovered ${result.kind} feed from ${result.provider}`)}</summary>
|
||||
</entry>`;
|
||||
})
|
||||
.join("\n");
|
||||
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||
<id>logicsrc:feed-discovery:${escapeXml(response.normalizedQuery)}</id>
|
||||
<title>LogicSRC feed discovery: ${escapeXml(response.query)}</title>
|
||||
<updated>${updated}</updated>
|
||||
${entries}
|
||||
</feed>`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue