npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-generator-json-feed

v2.0.4

Published

A JSON Feed/RSS generator for Hexo

Downloads

19

Readme

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.

RSS JSON Feed

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. :smirk:

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: hexo.config.title,
	description: hexo.config.description,
	language: hexo.config.language,
	link: hexo.config.url,
	webMaster: hexo.config.author,
	pubDate: post.date, // Last published post pubdate, UTC format, RSS pattern
	lastBuildDate: new Date(), // JSON file build datetime, UTC format, RSS pattern
	generator: 'hexo-generator-json-feed',
	items: [
		{
			title: post.title,
			link: post.permalink,
			description: post.excerpt ? post.excerpt : post.content, // only text minified ;)
			pubDate: post.date, // UTC format, RSS pattern
			guid: post.permalink,
			category: post.categories.length ? post.categories : post.tags // 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: hexo.config.title,
	home_page_url: hexo.config.url,
	feed_url: `${hexo.config.url}/feed.json`,
	author: {
		name: hexo.config.author
	},
	items: [
		{
			id: post.permalink,
			url: post.permalink,
			title: post.title,
			content_html: post.content,
			content_text: post.content, // only text minified ;)
			summary: post.excerpt || post.content, // only text minified ;)
			date_published: post.date, // JSON universal date RFC 3339 format
			tags: [...categories.names, ...tags.names]
		}
	]
}

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.