TypeScript types for JSON Feed 1.1.
npm install @json-feed-types/1_1TypeScript types for JSON Feed 1.1.
```
npm install --save-dev @json-feed-types/1_1
`
import Feed from '@json-feed-types/1_1'
const feed: Feed = {
version: 'https://jsonfeed.org/version/1.1',
title: 'JSON Feed',
icon: 'https://micro.blog/jsonfeed/avatar.jpg',
home_page_url: 'https://www.jsonfeed.org/',
feed_url: 'https://www.jsonfeed.org/feed.json',
items: [
{
id: 'http://jsonfeed.micro.blog/2020/08/07/json-feed-version.html',
title: 'JSON Feed version 1.1',
content_html:
'
We’ve updated the spec to version 1.1. It’s a minor update to JSON Feed, clarifying a few things in the spec and adding a couple new fields such as authors and language.
For version 1.1, we’re starting to move to the more specific MIME type application/feed+json. Clients that parse HTML to discover feeds should prefer that MIME type, while still falling back to accepting application/json too.
The code page has also been updated with several new code libraries and apps that support JSON Feed.
\n',Types
- Feed
- Attachment
- Author
- Hub
- Item
Extensions
> Publishers can use custom objects in JSON Feeds. Names must start with an \_ character followed by a letter. Custom objects can appear anywhere in a feed.
The
Feed, Author, Item, Attachment, and Hub types are generic. To define extensions, provide a map:`
import Feed from '@json-feed-types/1_1'type CustomFeed = Feed<{
feed: {
_meta: {
copyright: string
}
}
author: {
_meta: {
id: string
}
}
item: {
_meta: {
type: 'SHORT_EPISODE' | 'LONG_EPISODE' | 'SPECIAL_EVENT'
}
}
attachment: {
_image?: {
dimensions: [width: number, height: number]
}
}
hub: {
_meta: {
instructions: string
}
}
}>
``
import { Item } from '@json-feed-types/1_1'type CustomItem = Item<{
feed: {
_meta: {
copyright: string
}
}
author: {
_meta: {
id: string
}
}
item: {
_meta: {
type: 'SHORT_EPISODE' | 'LONG_EPISODE' | 'SPECIAL_EVENT'
}
}
attachment: {
_image?: {
dimensions: [width: number, height: number]
}
}
hub: {
_meta: {
instructions: string
}
}
}>
`The
ExtensionMap type from @json-feed-types/common can be used to define an extension map outside of the generic types:`
import { ExtensionMap } from '@json-feed-types/common'type MyExtensionMap: ExtensionMap = {
feed: {
_meta: {
copyright: string
}
}
author: {
_meta: {
id: string
}
}
item: {
_meta: {
type: 'SHORT_EPISODE' | 'LONG_EPISODE' | 'SPECIAL_EVENT'
}
}
attachment: {
_image?: {
dimensions: [width: number, height: number]
}
}
hub: {
_meta: {
instructions: string
}
}
}
``