astro-jsonfeed
v1.0.2
Published
Generate a JSON Feed for your Astro site.
Readme
astro-jsonfeed
Add a JSON Feed to blogs, changelogs, or any chronological content on Astro sites.
Installation and use
Install
astro-jsonfeedusing your preferred package manager:- npm:
npm install astro-jsonfeed - pnpm:
pnpm add astro-jsonfeed - Yarn:
yarn add astro-jsonfeed
- npm:
Create a file in the
src/pagesdirectory with a name of your choice and the extension.json.js(or.json.tsif you are using Typescript) to be used as the output URL for the feed. A somewhat common convention is to usefeed.json.Import the
jsonFeed()helper fromastro-jsonfeedpackage into your page file and export a function that returns it using the following parameters:
import jsonFeed from "astro-jsonfeed";
export function GET(context) {
return jsonFeed({
title: "Arrietty's Blog",
description: "Notes from under the floorboards.",
items: [
{
id: "/kitchen",
url: new URL("/kitchen", context.site).href,
title: "First Expedition to the Kitchen",
content_text:
"Father finally said I could come up. Up! Through the wall, past the clock, all the way to the kitchen.",
content_html:
"<p>Father finally said I could come up. Up! Through the wall, past the clock, all the way to the kitchen.</p>",
date_published: "2026-05-25T23:30:15-04:00",
tags: ["borrows"],
},
],
});
}