all repos — home @ 22289ffa2ff5d16c2052aa3e3a79998809a3dd9a

Improve XML feeds
Tim Izzo tim@5ika.ch
Sun, 30 Oct 2022 10:34:25 +0000
commit

22289ffa2ff5d16c2052aa3e3a79998809a3dd9a

parent

a5aea38fb6de078065771c6cae73ca175b51cd4c

4 files changed, 14 insertions(+), 9 deletions(-)

jump to
M README.mdREADME.md

@@ -13,8 +13,8 @@ 3. Go to `home` and generate posts from JSON-LD with `yarn build`

## ToDo -- [ ] Adapt git hook on server to deploy on each push - +- [ ] Adapt self URL in atom feeds for html and gmi +- [ ] Add summary to atom feeds ## Inspiration
M bin/generate-posts.jsbin/generate-posts.js

@@ -21,7 +21,7 @@

// Set posts list in index.html const postsList = jsonLd.items .sort((itemA, itemB) => new Date(itemB.published) - new Date(itemA.published)) - .map(item => { + .map((item) => { const date = new Date(item.published).toLocaleDateString(); return `<li><a href="/posts/${item["@id"]}.html">${date} - ${item.name}</a></li>`; });
M generator/atom.tsgenerator/atom.ts

@@ -7,6 +7,7 @@ return stringify({

xml: { "@version": "1.0", "@encoding": "UTF-8" }, feed: { "@xmlns": "http://www.w3.org/2005/Atom", + id: collection.url, title: collection.name, subtitle: collection.summary, updated: collection.published,

@@ -16,15 +17,19 @@ "@href": collection.url,

"@rel": "alternate", }, { - "@href": `${collection.url}/atom.xml`, + "@href": `${collection.url}/atom-html.xml`, // TODO: Set gemini or html "@rel": "self", }, ], - entry: collection.items?.map(item => ({ - id: item["@id"], + entry: collection.items?.map((item) => ({ + id: item.url, title: item.name, updated: item.published, - author: item.attributedTo, + author: { + name: item.attributedTo.name, + uri: item.attributedTo.url, + email: item.attributedTo.email, + }, link: { "@href": item.url, "@rel": "alternate",
M generator/rss.tsgenerator/rss.ts

@@ -14,10 +14,10 @@ link: collection.url,

lastBuildDate: collection.published, ttl: 1800, - item: collection.items.map(item => ({ + item: collection.items.map((item) => ({ title: item.name, link: item.url, - guid: item["@id"], + guid: item.url, pubDate: item.published, })), },