diff options
author | 2022-12-27 23:50:11 +0800 | |
---|---|---|
committer | 2022-12-27 10:50:11 -0500 | |
commit | 68c20be66b197e6c525cd292823a3a728f238547 (patch) | |
tree | c3d76da8bf073da5a5d713fe2c5fd2d7d73d2c3b /packages/astro-rss/src | |
parent | 9674cf56c561af8f13def0266b0539507a80000d (diff) | |
download | astro-68c20be66b197e6c525cd292823a3a728f238547.tar.gz astro-68c20be66b197e6c525cd292823a3a728f238547.tar.zst astro-68c20be66b197e6c525cd292823a3a728f238547.zip |
fix: filter out draft item from glob result (#5612)
* fix: filter out draft item from glob result
* test: rss should ignore draft
* build: add changeset
* build: major version
* feat: add `drafts` option
* Add README docs
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Diffstat (limited to 'packages/astro-rss/src')
-rw-r--r-- | packages/astro-rss/src/index.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index a138bebde..667ab1c9d 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -28,6 +28,8 @@ type RSSOptions = { stylesheet?: string | boolean; /** Specify custom data in opening of file */ customData?: string; + /** Whether to include drafts or not */ + drafts?: boolean; }; type RSSFeedItem = { @@ -43,6 +45,8 @@ type RSSFeedItem = { content?: string; /** Append some other XML-valid data to this item */ customData?: string; + /** Whether draft or not */ + draft?: boolean; }; type GenerateRSSArgs = { @@ -72,6 +76,7 @@ function mapGlobResult(items: GlobResult): Promise<RSSFeedItem[]> { pubDate: frontmatter.pubDate, description: frontmatter.description, customData: frontmatter.customData, + draft: frontmatter.draft, }; }) ); @@ -87,6 +92,9 @@ export default async function getRSS(rssOptions: RSSOptions) { if (isGlobResult(items)) { items = await mapGlobResult(items); + if (!rssOptions.drafts) { + items = items.filter((item) => !item.draft); + } } return { |