JSON Feed 1.1 describes a subscription feed in plain JSON — no XML parsing required. xfm-plugin-feed-json writes feed.json at the end of each build, complementing the built-in rss plugin: readers, automation scripts, and browser-side code can all consume it directly.
What it solves
XML is a historical tax paid for the sake of feed readers; programs consuming a feed still need a parser. With feed.json, a front end gets every post with one call — fetch('/feed.json').then(r => r.json()) — which makes a "latest posts" sidebar, build-time notifications, or feeding an AI pipeline far more direct than scraping XML.
Install and configure
npm i -D xfm-plugin-feed-jsonInstall and it works. Two options:
// xfm.config.mjs
export default {
feedJson: {
path: 'feed.json', // output path
limit: 20, // item count, default 20
},
};Output and fields
One file, feed.json (valid JSON, two-space indented, trailing newline). Top-level fields: version (JSON Feed 1.1), title, home_page_url, feed_url, description, language (from site.lang, default zh-CN), and authors when site.author is configured. Each item carries:
idandurl: the page's absolute addresstitle,content_html(the full post HTML), andsummary(front-matterdescriptionor the excerpt)date_publishedanddate_modified(fromupdated || date; date-only values become midnight UTC)tagsandauthors, present only when non-empty
Inclusion rules match the rss plugin: posts need a date, must not be type: page, must not set rss: false in front-matter, and must not be the home page. Since 0.4.17 the same inStream filter applies, so translations on multilingual sites stay out of the default-language feed — one rss: false switch therefore governs both the XML and JSON feeds.
Notes
- The plugin is independent of the rss plugin, but feeds usually ship in pairs: XML for readers, JSON for programs.
content_htmlcontains full bodies, so file size grows with your posts; cap it withlimiton large sites.- To exclude a single post, set
rss: falsein its front-matter.
Comments