{"id":13716971,"url":"https://github.com/syntax-tree/xast-util-feed","last_synced_at":"2025-06-29T22:03:38.096Z","repository":{"id":37500520,"uuid":"329915876","full_name":"syntax-tree/xast-util-feed","owner":"syntax-tree","description":"xast utility to build feeds (rss, atom)","archived":false,"fork":false,"pushed_at":"2023-07-19T08:31:15.000Z","size":130,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-24T07:40:45.983Z","etag":null,"topics":["atom","feed","rss","xast","xast-util","xml"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"funding":{"github":"unifiedjs","open_collective":"unified"},"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-01-15T13:12:10.000Z","updated_at":"2024-11-06T13:14:53.000Z","dependencies_parsed_at":"2024-01-14T22:13:43.397Z","dependency_job_id":null,"html_url":"https://github.com/syntax-tree/xast-util-feed","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.02857142857142858,"last_synced_commit":"ea6548c8ca7f5ac14f3716f9db7f90170575f8d6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/xast-util-feed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fxast-util-feed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fxast-util-feed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fxast-util-feed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fxast-util-feed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/xast-util-feed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fxast-util-feed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262574861,"owners_count":23330883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["atom","feed","rss","xast","xast-util","xml"],"created_at":"2024-08-03T00:01:16.133Z","updated_at":"2025-06-29T22:03:38.043Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# xast-util-feed\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[xast][] utility to build (web) feeds ([RSS][], [Atom][]).\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`atom(channel, data)`](#atomchannel-data)\n    *   [`rss(channel, data)`](#rsschannel-data)\n    *   [`Author`](#author)\n    *   [`Channel`](#channel)\n    *   [`Enclosure`](#enclosure)\n    *   [`Entry`](#entry)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Related](#related)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package generates RSS or Atom feeds from data.\n\n## When should I use this?\n\nThis package helps you add feeds to your site.\nIt focusses on a small set of widely used and supported parts of feeds.\nIt has a few good options instead of overwhelming with hundreds of things to\nconfigure.\nIf you do need more things, well: this utility gives you a syntax tree, which\nyou can change.\n\nIt’s good to use this package to build several feeds and to only include recent\nposts (often 15-20 items are included in a channel).\nYou should make a channel for all your posts; when relevant, separate channels\nper language as well; and potentially, channels per post type (such as separate\nones for blog posts, notes, and images).\n\nJust using either RSS or Atom is probably fine: no need to do both.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install xast-util-feed\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {atom, rss} from 'https://esm.sh/xast-util-feed@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {atom, rss} from 'https://esm.sh/xast-util-feed@2?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {atom, rss} from 'xast-util-feed'\nimport {toXml} from 'xast-util-to-xml'\n\nconst channel = {\n  title: 'NYT \u003e Top Stories',\n  url: 'https://www.nytimes.com',\n  feedUrl: 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml',\n  lang: 'en',\n  author: 'The New York Times Company'\n}\n\nconst data = [\n  {\n    title: 'Senate Balances Impeachment Trial With an Incoming President',\n    url:\n      'https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html',\n    descriptionHtml: '\u003cp\u003eSenate leaders etc etc etc.\u003c/p\u003e',\n    author: 'Nicholas Fandos and Catie Edmondson',\n    published: 'Fri, 15 Jan 2021 01:18:49 +0000',\n    tags: ['Senate', 'Murkowski, Lisa', 'Trump, Donald J']\n  }\n]\n\nconsole.log(toXml(rss(channel, data)))\nconsole.log(toXml(atom(channel, data)))\n```\n\nYields (pretty printed):\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003crss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:atom=\"http://www.w3.org/2005/Atom\"\u003e\n  \u003cchannel\u003e\n    \u003ctitle\u003eNYT \u003e Top Stories\u003c/title\u003e\n    \u003cdescription\u003e\u003c/description\u003e\n    \u003clink\u003ehttps://www.nytimes.com/\u003c/link\u003e\n    \u003clastBuildDate\u003eSun, 17 Jan 2021 09:00:54 GMT\u003c/lastBuildDate\u003e\n    \u003cdc:date\u003e2021-01-17T09:00:54.781Z\u003c/dc:date\u003e\n    \u003catom:link href=\"https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml\" rel=\"self\" type=\"application/rss+xml\"\u003e\u003c/atom:link\u003e\n    \u003clanguage\u003een\u003c/language\u003e\n    \u003cdc:language\u003een\u003c/dc:language\u003e\n    \u003ccopyright\u003e© 2021 The New York Times Company\u003c/copyright\u003e\n    \u003cdc:rights\u003e© 2021 The New York Times Company\u003c/dc:rights\u003e\n    \u003citem\u003e\n      \u003ctitle\u003eSenate Balances Impeachment Trial With an Incoming President\u003c/title\u003e\n      \u003cdc:creator\u003eNicholas Fandos and Catie Edmondson\u003c/dc:creator\u003e\n      \u003clink\u003ehttps://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html\u003c/link\u003e\n      \u003cguid isPermaLink=\"false\"\u003ehttps://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html\u003c/guid\u003e\n      \u003cpubDate\u003eFri, 15 Jan 2021 01:18:49 GMT\u003c/pubDate\u003e\n      \u003cdc:date\u003e2021-01-15T01:18:49.000Z\u003c/dc:date\u003e\n      \u003ccategory\u003eSenate\u003c/category\u003e\n      \u003ccategory\u003eMurkowski, Lisa\u003c/category\u003e\n      \u003ccategory\u003eTrump, Donald J\u003c/category\u003e\n      \u003cdescription\u003e\u0026#x3C;p\u003eSenate leaders etc etc etc.\u0026#x3C;/p\u003e\u003c/description\u003e\n    \u003c/item\u003e\n  \u003c/channel\u003e\n\u003c/rss\u003e\n```\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cfeed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"en\"\u003e\n  \u003ctitle\u003eNYT \u003e Top Stories\u003c/title\u003e\n  \u003csubtitle\u003e\u003c/subtitle\u003e\n  \u003clink\u003ehttps://www.nytimes.com/\u003c/link\u003e\n  \u003cid\u003ehttps://www.nytimes.com/\u003c/id\u003e\n  \u003cupdated\u003eSun, 17 Jan 2021 09:00:54 GMT\u003c/updated\u003e\n  \u003clink href=\"https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml\" rel=\"self\" type=\"application/atom+xml\"\u003e\u003c/link\u003e\n  \u003crights\u003e© 2021 The New York Times Company\u003c/rights\u003e\n  \u003cauthor\u003e\n    \u003cname\u003eThe New York Times Company\u003c/name\u003e\n  \u003c/author\u003e\n  \u003ccategory term=\"Senate\"\u003e\u003c/category\u003e\n  \u003ccategory term=\"Murkowski, Lisa\"\u003e\u003c/category\u003e\n  \u003ccategory term=\"Trump, Donald J\"\u003e\u003c/category\u003e\n  \u003centry\u003e\n    \u003ctitle\u003eSenate Balances Impeachment Trial With an Incoming President\u003c/title\u003e\n    \u003cauthor\u003e\n      \u003cname\u003eNicholas Fandos and Catie Edmondson\u003c/name\u003e\n    \u003c/author\u003e\n    \u003clink href=\"https://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html\"\u003e\u003c/link\u003e\n    \u003cid\u003ehttps://www.nytimes.com/2021/01/14/us/politics/impeachment-senate-trial-trump.html\u003c/id\u003e\n    \u003cpublished\u003e2021-01-15T01:18:49.000Z\u003c/published\u003e\n    \u003ccontent type=\"html\"\u003e\u0026#x3C;p\u003eSenate leaders etc etc etc.\u0026#x3C;/p\u003e\u003c/content\u003e\n  \u003c/entry\u003e\n\u003c/feed\u003e\n```\n\n## API\n\nThis package exports the identifiers [`atom`][api-atom] and [`rss`][api-rss].\nThere is no default export.\n\n### `atom(channel, data)`\n\nBuild an [Atom][] feed.\n\n###### Parameters\n\n*   `channel` ([`Channel`][api-channel])\n    — data on the feed (the group of items)\n*   `data` ([`Array\u003cEntry\u003e`][api-entry], optional)\n    — list of entries\n\n###### Returns\n\nAtom feed ([`Root`][root]).\n\n### `rss(channel, data)`\n\nBuild an [RSS][] feed.\n\n###### Parameters\n\n*   `channel` ([`Channel`][api-channel])\n    — data on the feed (the group of items)\n*   `data` ([`Array\u003cEntry\u003e`][api-entry], optional)\n    — list of entries\n\n###### Returns\n\nRSS feed ([`Root`][root]).\n\n### `Author`\n\nAuthor object (TypeScript type).\n\n##### Fields\n\n###### `name`\n\nName (`string`, **required**, example: `'Acme, Inc.'` or `'Jane Doe'`).\n\n###### `email`\n\nEmail address (`string`, optional, ,example: `john@example.org`)\n\n###### `url`\n\nURL to author (`string`, optional, example: `'https://example.org/john'`).\n\n`url` is used in `atom`, not in `rss`.\n\n### `Channel`\n\nData on the feed (the group of items) (TypeScript type).\n\n##### Fields\n\n###### `title`\n\nTitle of the channel (`string`, **required**, example: `Zimbabwe | The\nGuardian`).\n\n###### `url`\n\nFull URL to the *site* (`string`, **required**, example:\n`'https://www.theguardian.com/world/zimbabwe'`).\n\n###### `feedUrl`\n\nFull URL to this channel (`string?`, example: `'https://www.adweek.com/feed/'`).\n\nMake sure to pass different ones to `rss` and `atom` when you build both!\n\nYou *should* define this.\n\n###### `description`\n\nShort description of the channel (`string?`, example: `Album Reviews`).\n\nYou *should* define this.\n\n###### `lang`\n\n[BCP 47][bcp47] language tag representing the language of the whole channel\n(`string?`, example: `'fr-BE'`).\n\nYou *should* define this.\n\n###### `author`\n\nOptional author of the whole channel (`string` or [`Author`][api-author]).\n\nEither `string`, in which case it’s as passing `{name: string}`.\nOr an author object.\n\n###### `tags`\n\nCategories of the channel (`Array\u003cstring\u003e?`, example: `['JavaScript',\n'React']`).\n\n### `Enclosure`\n\nMedia (TypeScript type).\n\n##### Fields\n\n###### `url`\n\nFull URL to the resource (`string`, **required**, example:\n`'http://dallas.example.com/joebob_050689.mp3'`).\n\n###### `size`\n\nResource size in bytes (`number`, **required**, example: `24986239`).\n\n###### `type`\n\nMime type of the resource (`string`, **required**, example: `'audio/mpeg'`).\n\n### `Entry`\n\nData on a single item (TypeScript type).\n\n##### Fields\n\n###### `title`\n\nTitle of the item (`string?`, example: `'Playboi Carti: Whole Lotta Red'`).\n\nEither `title`, `description`, or `descriptionHtml` must be set.\n\n###### `description`\n\nEither the whole post or an excerpt of it (`string?`, example: `'Lorem'`).\n\nShould be plain text.\n`descriptionHtml` is preferred over plain text `description`.\n\nEither `title`, `description`, or `descriptionHtml` must be set.\n\n###### `descriptionHtml`\n\nEither the whole post or an excerpt of it (`string?`, example: `'\u003cp\u003eLorem\u003c/p\u003e'`).\n\nShould be serialized HTML.\n`descriptionHtml` is preferred over plain text `description`.\n\nEither `title`, `description`, or `descriptionHtml` must be set.\n\n###### `author`\n\nEntry version of `channel.author`.\n\nYou *should* define this.\n\nFor `atom`, it is required to either set `channel.author` or set `author` on all\nentries.\n\n###### `url`\n\nFull URL of this entry on the *site* (`string?`, example:\n`'https://pitchfork.com/reviews/albums/roberta-flack-first-take'`).\n\n###### `published`\n\nWhen the entry was first published (`Date` or value for `new Date(x)`,\noptional).\n\n###### `modified`\n\nWhen the entry was last modified (`Date` or value for `new Date(x)`, optional).\n\n###### `tags`\n\nCategories of the entry (`Array\u003cstring\u003e?`, example: `['laravel',\n'debugging']`).\n\n###### `enclosure`\n\nAttached media ([`Enclosure?`][api-enclosure]).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Author`][api-author],\n[`Channel`][api-channel],\n[`Enclosure`][api-enclosure], and\n[`Entry`][api-entry].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `xast-util-feed@^2`,\ncompatible with Node.js 16.\n\n## Security\n\nXML can be a dangerous language: don’t trust user-provided data.\n\n## Related\n\n*   [`xast-util-to-xml`](https://github.com/syntax-tree/xast-util-to-xml)\n    — serialize xast to XML\n*   [`xast-util-sitemap`](https://github.com/syntax-tree/xast-util-sitemap)\n    — build a sitemap\n*   [`xastscript`](https://github.com/syntax-tree/xastscript)\n    — create xast trees\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][wooorm]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/xast-util-feed/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/xast-util-feed/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/xast-util-feed.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/xast-util-feed\n\n[downloads-badge]: https://img.shields.io/npm/dm/xast-util-feed.svg\n\n[downloads]: https://www.npmjs.com/package/xast-util-feed\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=xast-util-feed\n\n[size]: https://bundlejs.com/?q=xast-util-feed\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[wooorm]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[xast]: https://github.com/syntax-tree/xast\n\n[root]: https://github.com/syntax-tree/xast#root\n\n[rss]: https://www.rssboard.org/rss-specification\n\n[atom]: https://tools.ietf.org/html/rfc4287\n\n[bcp47]: https://github.com/wooorm/bcp-47\n\n[api-atom]: #atomchannel-data\n\n[api-rss]: #rsschannel-data\n\n[api-author]: #author\n\n[api-channel]: #channel\n\n[api-enclosure]: #enclosure\n\n[api-entry]: #entry\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["xast utilities"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fxast-util-feed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fxast-util-feed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fxast-util-feed/lists"}