feeds
Feeds of articles the plugin provides. A household follows them like any other source: the plugin gives the articles, and Hodi files them under the right topic.
Where in Hodi
A feed of articles of the plugin shows in Settings › Sources, among the suggested sources, in the topic the feed gives. Once the household follows the feed, the feed's articles arrive in the household's stream, with those of the other sources.
A feed needs no web part: everything happens in plugin.json and in the server part. For that reason, feeds isn't a key of definePlugin(), but a field of plugin.json.
Declaring the feed
In plugin.json, the feeds field lists the plugin's feeds. The network permission lists the sites the plugin reads:
"permissions": {
"network": [
"example.com"
]
},
"feeds": [
{
"key": "news",
"name": "Example",
"site": "example.com",
"lang": "en",
"topic": "tech"
}
]Here are the fields of a feed of feeds:
keystringThe feed's technical name, the same as in feeds in the server part.
namestringThe name the household sees, 60 characters at most.
sitestringThe site of the feed's articles. This site must be in network.
lang'fr' | 'en'The language of the feed's articles.
topicstringThe topic the feed goes under, such as tech, world or climate.
Filling the feed
In the server part, feeds gives one function per feed, with the same key as in plugin.json. This function returns the list of the feed's articles:
const plugin: ServerPlugin = {
feeds: {
news: async ctx => {
const { text } = await ctx.fetchText('https://example.com/api/latest')
return JSON.parse(text).map(item => ({
title: item.title,
link: item.url,
summary: item.lead
}))
}
}
}An article's fields
titlestringThe article's title.
linkstringThe article's address, in https, on the feed's site.
summary?stringThe article's summary, in plain text.
publishedAt?string | numberThe article's date, ISO or in milliseconds.
image?stringThe https address of the article's image.
Good to know
- When Hodi reads a feed: every few minutes, as long as a household follows this feed.
- How many articles: 100 articles per read at most, and 5 feeds per plugin at most.
- How an article opens: with its summary and a link to the site, never in the reader.