summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.changeset/many-glasses-roll.md5
-rw-r--r--packages/astro-rss/src/index.ts7
-rw-r--r--packages/astro-rss/test/rss.test.js14
3 files changed, 26 insertions, 0 deletions
diff --git a/.changeset/many-glasses-roll.md b/.changeset/many-glasses-roll.md
new file mode 100644
index 000000000..7f9dd7313
--- /dev/null
+++ b/.changeset/many-glasses-roll.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/rss': patch
+---
+
+Throw the error when 'site' option is missing
diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts
index d715b7dc0..9f55ee9f1 100644
--- a/packages/astro-rss/src/index.ts
+++ b/packages/astro-rss/src/index.ts
@@ -76,10 +76,17 @@ function mapGlobResult(items: GlobResult): Promise<RSSFeedItem[]> {
}
export default async function getRSS(rssOptions: RSSOptions) {
+ const { site } = rssOptions;
let { items } = rssOptions;
+
+ if (!site) {
+ throw new Error('[RSS] the "site" option is required, but no value was given.');
+ }
+
if (isGlobResult(items)) {
items = await mapGlobResult(items);
}
+
return {
body: await generateRSS({
rssOptions,
diff --git a/packages/astro-rss/test/rss.test.js b/packages/astro-rss/test/rss.test.js
index 84cf7e36c..f4dc0ba6e 100644
--- a/packages/astro-rss/test/rss.test.js
+++ b/packages/astro-rss/test/rss.test.js
@@ -125,6 +125,20 @@ describe('rss', () => {
});
describe('errors', () => {
+ it('should provide a error message when a "site" option is missing', async () => {
+ try {
+ await rss({
+ title,
+ description,
+ items: [phpFeedItem, web1FeedItem]
+ });
+
+ chai.expect(false).to.equal(true, 'Should have errored');
+ } catch (err) {
+ chai.expect(err.message).to.contain('[RSS] the "site" option is required, but no value was given.');
+ }
+ });
+
it('should provide a good error message when a link is not provided', async () => {
try {
await rss({