diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:38:13 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:38:13 +0100 |
| commit | 82d310403c4bb09bc2f0a204b6374934a10cf348 (patch) | |
| tree | 488e93e373a7d9215531bb8fcfc37bcbb290d0fa /src/utils | |
| parent | f49dfba86b9ac745ddc374ee0f02f03d7e81d872 (diff) | |
refactor(config): move config from config dir to utils
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/config.ts | 16 | ||||
| -rw-r--r-- | src/utils/helpers/i18n.ts | 4 | ||||
| -rw-r--r-- | src/utils/helpers/rss.ts | 10 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/utils/config.ts b/src/utils/config.ts new file mode 100644 index 0000000..1c227cc --- /dev/null +++ b/src/utils/config.ts @@ -0,0 +1,16 @@ +export const settings = { + name: 'Armand Philippot', + baseline: 'Front-end developer', + copyright: { + startYear: '2012', + endYear: new Date().getFullYear(), + }, + locales: { + defaultLocale: 'fr', + defaultCountry: 'FR', + supported: ['en', 'fr'], + }, + postsPerPage: 10, + twitterId: '@ArmandPhilippot', + url: process.env.NEXT_PUBLIC_FRONTEND_URL, +}; diff --git a/src/utils/helpers/i18n.ts b/src/utils/helpers/i18n.ts index 16c83f4..c4734ad 100644 --- a/src/utils/helpers/i18n.ts +++ b/src/utils/helpers/i18n.ts @@ -1,11 +1,11 @@ -import { config } from '@config/website'; import { createIntl, createIntlCache, IntlShape } from '@formatjs/intl'; +import { settings } from '@utils/config'; import { readFile } from 'fs/promises'; import path from 'path'; type Messages = { [key: string]: string }; -export const defaultLocale = config.locales.defaultLocale; +export const defaultLocale = settings.locales.defaultLocale; /** * Load the translation for the provided locale. diff --git a/src/utils/helpers/rss.ts b/src/utils/helpers/rss.ts index 7806f7c..55b009a 100644 --- a/src/utils/helpers/rss.ts +++ b/src/utils/helpers/rss.ts @@ -1,7 +1,7 @@ -import { config } from '@config/website'; import { getPublishedPosts } from '@services/graphql/queries'; import { ArticlePreview } from '@ts/types/articles'; import { PostsList } from '@ts/types/blog'; +import { settings } from '@utils/config'; import { Feed } from 'feed'; const getAllPosts = async (): Promise<ArticlePreview[]> => { @@ -22,12 +22,12 @@ const getAllPosts = async (): Promise<ArticlePreview[]> => { export const generateFeed = async () => { const websiteUrl = process.env.FRONTEND_URL ? process.env.FRONTEND_URL : ''; const author = { - name: config.name, + name: settings.name, email: process.env.AUTHOR_EMAIL, link: websiteUrl, }; - const copyright = `${config.name} CC BY SA ${config.copyright.startYear} - ${config.copyright.endYear}`; - const title = `${config.name} | ${config.baseline}`; + const copyright = `${settings.name} CC BY SA ${settings.copyright.startYear} - ${settings.copyright.endYear}`; + const title = `${settings.name} | ${settings.baseline}`; const feed = new Feed({ author, @@ -39,7 +39,7 @@ export const generateFeed = async () => { }, generator: 'Feed & NextJS', id: websiteUrl, - language: config.locales.defaultLocale, + language: settings.locales.defaultLocale, link: websiteUrl, title, }); |
