diff --git a/src/pages/api/modules/rss/index.ts b/src/pages/api/modules/rss/index.ts index 7ea57572b..211e5bc37 100644 --- a/src/pages/api/modules/rss/index.ts +++ b/src/pages/api/modules/rss/index.ts @@ -1,17 +1,13 @@ -import Consola from 'consola'; - -import { getCookie } from 'cookies-next'; - -import { decode } from 'html-entities'; - import { NextApiRequest, NextApiResponse } from 'next'; - +import Consola from 'consola'; +import { getCookie } from 'cookies-next'; +import { decode } from 'html-entities'; import Parser from 'rss-parser'; - import { z } from 'zod'; + import { getConfig } from '../../../../tools/config/getConfig'; -import { IRssWidget } from '../../../../widgets/rss/RssWidgetTile'; import { Stopwatch } from '../../../../tools/shared/time/stopwatch.tool'; +import { IRssWidget } from '../../../../widgets/rss/RssWidgetTile'; type CustomItem = { 'media:content': string; @@ -28,6 +24,7 @@ const parser: Parser = new Parser({ const getQuerySchema = z.object({ widgetId: z.string().uuid(), + feedUrl: z.string(), }); export const Get = async (request: NextApiRequest, response: NextApiResponse) => { @@ -44,7 +41,6 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) => const rssWidget = config.widgets.find( (x) => x.type === 'rss' && x.id === parseResult.data.widgetId ) as IRssWidget | undefined; - if ( !rssWidget || !rssWidget.properties.rssFeedUrl || @@ -56,7 +52,7 @@ export const Get = async (request: NextApiRequest, response: NextApiResponse) => Consola.info('Requesting RSS feed...'); const stopWatch = new Stopwatch(); - const feed = await parser.parseURL(rssWidget.properties.rssFeedUrl); + const feed = await parser.parseURL(parseResult.data.feedUrl); Consola.info(`Retrieved RSS feed after ${stopWatch.getEllapsedMilliseconds()} milliseconds`); const orderedFeed = { diff --git a/src/widgets/rss/RssWidgetTile.tsx b/src/widgets/rss/RssWidgetTile.tsx index d2b8907ff..57a60773c 100644 --- a/src/widgets/rss/RssWidgetTile.tsx +++ b/src/widgets/rss/RssWidgetTile.tsx @@ -34,7 +34,7 @@ const definition = defineWidget({ options: { rssFeedUrl: { type: 'multiple-text', - defaultValue: ['https://japantimes.co.jp/feed'], + defaultValue: [], }, }, gridstack: {