hexo-generator-json-feed
Hexo (https://hexo.io/) plugin to generate a JSON file as site feed with posts contents for generic use or consumption.
It's useful to serve compact and agile content data for microservices like AJAX site search, Twitter typeahead or public API.
JSON output can be similar to RSS like structure (default) or the new JSON Feed spec.
News
It is now possible to:
- Select one of two specs to build your JSON: RSS like or JSON Feed
Breaking change:
The output file name now will be rss.json
or feed.json
, depends on your spec
setting. See bellow.
Installation
npm i -S hexo-generator-json-feed
Usage
Hexo will run the generator automagically when you run hexo serve
or hexo generate
.
😏
The output JSON file will depend on you spec
setting. Options are rss
(default) or feed
. This option defines the data structure and the name of the JSON file output.
RSS
Using the default settings (RSS), the rss.json
file will look like the following structure:
title: hexoconfigtitle description: hexoconfigdescription language: hexoconfiglanguage link: hexoconfigurl webMaster: hexoconfigauthor pubDate: postdate // Last published post pubdate, UTC format, RSS pattern lastBuildDate: // JSON file build datetime, UTC format, RSS pattern generator: 'hexo-generator-json-feed' items: title: posttitle link: postpermalink description: postexcerpt ? postexcerpt : postcontent // only text minified ;) pubDate: postdate // UTC format, RSS pattern guid: postpermalink category: postcategorieslength ? postcategories : posttags // Strings Array
JSON Feed
If you set spec
as feed
in your _config.yml
, like this:
jsonFeed: spec: feed
Then, your file will be a feed.json
looking like the following structure:
version: 'https://jsonfeed.org/version/1' title: hexoconfigtitle home_page_url: hexoconfigurl feed_url: `/feed.json` author: name: hexoconfigauthor items: id: postpermalink url: postpermalink title: posttitle content_html: postcontent content_text: postcontent // only text minified ;) summary: postexcerpt || postcontent // only text minified ;) date_published: postdate // JSON universal date RFC 3339 format tags: ...categoriesnames ...tagsnames
Settings
You can customize settings in _config.yml
.
Defaults
Default settings are:
jsonFeed: spec: rss limit: 25
hexo.util.stripHTML
is used to get only clean text for post excerpt
or content
.