diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-15 12:24:42 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-15 17:26:16 +0100 |
| commit | 0f38aee374029213a47ef7c29bd164093fe63c85 (patch) | |
| tree | 290cb6471fdfe81e4c42f4da4729247536b04ee7 /src/utils/helpers/rss.ts | |
| parent | be4d907efb4e2fa658baa7c9b276ed282eb920db (diff) | |
refactor(hooks): remove useSettings hook
It does not make sense to re-export an existing object through a hook.
On some pages both the hook and the object was imported...
It is better to use the CONFIG (previously settings) object directly
and by doing it we avoid potential errors because of conditional hooks.
Diffstat (limited to 'src/utils/helpers/rss.ts')
| -rw-r--r-- | src/utils/helpers/rss.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/utils/helpers/rss.ts b/src/utils/helpers/rss.ts index 0381c68..6de60cc 100644 --- a/src/utils/helpers/rss.ts +++ b/src/utils/helpers/rss.ts @@ -5,7 +5,7 @@ import { getTotalArticles, } from '../../services/graphql'; import type { Article } from '../../types'; -import { settings } from '../config'; +import { CONFIG } from '../config'; import { ROUTES } from '../constants'; /** @@ -32,25 +32,25 @@ const getAllArticles = async (): Promise<Article[]> => { */ export const generateFeed = async (): Promise<Feed> => { const author = { - name: settings.name, + name: CONFIG.name, email: process.env.APP_AUTHOR_EMAIL, - link: settings.url, + link: CONFIG.url, }; - const copyright = `${settings.name} CC BY SA ${settings.copyright.startYear} - ${settings.copyright.endYear}`; - const title = `${settings.name} | ${settings.baseline.fr}`; + const copyright = `${CONFIG.name} CC BY SA ${CONFIG.copyright.startYear} - ${CONFIG.copyright.endYear}`; + const title = `${CONFIG.name} | ${CONFIG.baseline}`; const feed = new Feed({ author, copyright, description: process.env.APP_FEED_DESCRIPTION, feedLinks: { - json: `${settings.url}${ROUTES.RSS}/json`, - atom: `${settings.url}${ROUTES.RSS}/atom`, + json: `${CONFIG.url}${ROUTES.RSS}/json`, + atom: `${CONFIG.url}${ROUTES.RSS}/atom`, }, generator: 'Feed & NextJS', - id: settings.url, - language: settings.locales.defaultLocale, - link: settings.url, + id: CONFIG.url, + language: CONFIG.locales.defaultLocale, + link: CONFIG.url, title, }); @@ -62,7 +62,7 @@ export const generateFeed = async (): Promise<Feed> => { date: new Date(article.meta.dates.publication), description: article.intro, id: `${article.id}`, - link: `${settings.url}${ROUTES.ARTICLE}/${article.slug}`, + link: `${CONFIG.url}${ROUTES.ARTICLE}/${article.slug}`, title: article.title, }); }); |
