diff --git a/src/pages/api/configs/[slug].ts b/src/pages/api/configs/[slug].ts index b7cbfea8d..e7f37f4ef 100644 --- a/src/pages/api/configs/[slug].ts +++ b/src/pages/api/configs/[slug].ts @@ -8,6 +8,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { BackendConfigType, ConfigType } from '../../../types/config'; import { getConfig } from '../../../tools/config/getConfig'; +import widgets from '../../../widgets'; +import { IRssWidget } from '../../../widgets/rss/RssWidgetTile'; function Put(req: NextApiRequest, res: NextApiResponse) { if (process.env.DISABLE_EDIT_MODE === 'true') { @@ -30,16 +32,17 @@ function Put(req: NextApiRequest, res: NextApiResponse) { const previousConfig = getConfig(slug); - const newConfig: BackendConfigType = { + let newConfig: BackendConfigType = { ...config, apps: [ ...config.apps.map((app) => ({ ...app, network: { ...app.network, - statusCodes: app.network.okStatus === undefined ? - app.network.statusCodes : - app.network.okStatus.map((x) => x.toString()), + statusCodes: + app.network.okStatus === undefined + ? app.network.statusCodes + : app.network.okStatus.map((x) => x.toString()), okStatus: undefined, }, integration: { @@ -83,6 +86,30 @@ function Put(req: NextApiRequest, res: NextApiResponse) { ], }; + newConfig = { + ...newConfig, + widgets: [ + ...newConfig.widgets.map((x) => { + if (x.type !== 'rss') { + return x; + } + + const rssWidget = x as IRssWidget; + + return { + ...rssWidget, + properties: { + ...rssWidget.properties, + rssFeedUrl: + typeof rssWidget.properties.rssFeedUrl === 'string' + ? [rssWidget.properties.rssFeedUrl] + : rssWidget.properties.rssFeedUrl, + }, + } as IRssWidget; + }), + ], + }; + // Save the body in the /data/config folder with the slug as filename const targetPath = path.join('data/configs', `${slug}.json`); fs.writeFileSync(targetPath, JSON.stringify(newConfig, null, 2), 'utf8'); diff --git a/src/widgets/rss/RssWidgetTile.tsx b/src/widgets/rss/RssWidgetTile.tsx index c3022fd00..07e19ea71 100644 --- a/src/widgets/rss/RssWidgetTile.tsx +++ b/src/widgets/rss/RssWidgetTile.tsx @@ -120,58 +120,59 @@ function RssTile({ widget }: RssTileProps) { {data.map((feed, index) => ( - {feed.feed && feed.feed.items.map((item: any, index: number) => ( - - {item.enclosure && ( - // eslint-disable-next-line @next/next/no-img-element - backdrop - )} - - + {feed.feed && + feed.feed.items.map((item: any, index: number) => ( + {item.enclosure && ( - - - + // eslint-disable-next-line @next/next/no-img-element + backdrop )} - - {item.categories && ( - - {item.categories.map((category: any, categoryIndex: number) => ( - {category} - ))} - - )} - {item.title} - - {item.content} - - - {item.pubDate && ( - + + {item.enclosure && ( + + + )} + + {item.categories && ( + + {item.categories.map((category: any, categoryIndex: number) => ( + {category} + ))} + + )} + + {item.title} + + {item.content} + + + {item.pubDate && ( + + )} + - - - ))} + + ))} ))}