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/components | |
| parent | f49dfba86b9ac745ddc374ee0f02f03d7e81d872 (diff) | |
refactor(config): move config from config dir to utils
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Branding/Branding.tsx | 18 | ||||
| -rw-r--r-- | src/components/Breadcrumb/Breadcrumb.tsx | 12 | ||||
| -rw-r--r-- | src/components/Comment/Comment.tsx | 10 | ||||
| -rw-r--r-- | src/components/Copyright/Copyright.tsx | 6 | ||||
| -rw-r--r-- | src/components/Layouts/Layout.tsx | 36 | ||||
| -rw-r--r-- | src/components/MDX/CodeBlock/CodeBlock.tsx | 4 | ||||
| -rw-r--r-- | src/components/PostMeta/PostMeta.tsx | 4 | ||||
| -rw-r--r-- | src/components/PostPreview/PostPreview.tsx | 14 | ||||
| -rw-r--r-- | src/components/ProjectSummary/ProjectSummary.tsx | 6 | ||||
| -rw-r--r-- | src/components/Widgets/RecentPosts/RecentPosts.tsx | 4 |
10 files changed, 56 insertions, 58 deletions
diff --git a/src/components/Branding/Branding.tsx b/src/components/Branding/Branding.tsx index efb3a49..adefbca 100644 --- a/src/components/Branding/Branding.tsx +++ b/src/components/Branding/Branding.tsx @@ -1,5 +1,5 @@ import photo from '@assets/images/armand-philippot.jpg'; -import { config } from '@config/website'; +import { settings } from '@utils/config'; import Head from 'next/head'; import Image from 'next/image'; import Link from 'next/link'; @@ -18,12 +18,12 @@ const Branding: BrandingReturn = ({ isHome = false }) => { const schemaJsonLd: WithContext<Person> = { '@context': 'https://schema.org', '@type': 'Person', - '@id': `${config.url}/#branding`, - name: config.name, - url: config.url, - jobTitle: config.baseline, + '@id': `${settings.url}/#branding`, + name: settings.name, + url: settings.url, + jobTitle: settings.baseline, image: photo.src, - subjectOf: { '@id': `${config.url}` }, + subjectOf: { '@id': `${settings.url}` }, }; return ( @@ -45,7 +45,7 @@ const Branding: BrandingReturn = ({ isHome = false }) => { description: 'Branding: branding name picture.', }, { - brandingName: config.name, + brandingName: settings.name, } )} layout="responsive" @@ -57,10 +57,10 @@ const Branding: BrandingReturn = ({ isHome = false }) => { </div> <TitleTag className={styles.name}> <Link href="/"> - <a className={styles.link}>{config.name}</a> + <a className={styles.link}>{settings.name}</a> </Link> </TitleTag> - <p className={styles.job}>{config.baseline}</p> + <p className={styles.job}>{settings.baseline}</p> </div> </> ); diff --git a/src/components/Breadcrumb/Breadcrumb.tsx b/src/components/Breadcrumb/Breadcrumb.tsx index 30179be..914a175 100644 --- a/src/components/Breadcrumb/Breadcrumb.tsx +++ b/src/components/Breadcrumb/Breadcrumb.tsx @@ -1,4 +1,4 @@ -import { config } from '@config/website'; +import { settings } from '@utils/config'; import Head from 'next/head'; import Link from 'next/link'; import { useRouter } from 'next/router'; @@ -71,7 +71,7 @@ const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { defaultMessage: 'Home', description: 'Breadcrumb: Home item', }), - item: config.url, + item: settings.url, }; items.push(homepage); @@ -84,7 +84,7 @@ const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { defaultMessage: 'Blog', description: 'Breadcrumb: Blog item', }), - item: `${config.url}/blog`, + item: `${settings.url}/blog`, }; items.push(blog); @@ -98,7 +98,7 @@ const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { defaultMessage: 'Projects', description: 'Breadcrumb: Projects item', }), - item: `${config.url}/projets`, + item: `${settings.url}/projets`, }; items.push(blog); @@ -108,7 +108,7 @@ const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { '@type': 'ListItem', position: items.length + 1, name: pageTitle, - item: `${config.url}${router.asPath}`, + item: `${settings.url}${router.asPath}`, }; items.push(currentPage); @@ -119,7 +119,7 @@ const Breadcrumb = ({ pageTitle }: { pageTitle: string }) => { const schemaJsonLd: WithContext<BreadcrumbList> = { '@context': 'https://schema.org', '@type': 'BreadcrumbList', - '@id': `${config.url}/#breadcrumb`, + '@id': `${settings.url}/#breadcrumb`, itemListElement: getElementsSchema(), }; diff --git a/src/components/Comment/Comment.tsx b/src/components/Comment/Comment.tsx index e95a378..4835f8c 100644 --- a/src/components/Comment/Comment.tsx +++ b/src/components/Comment/Comment.tsx @@ -1,7 +1,7 @@ import { Button } from '@components/Buttons'; import CommentForm from '@components/CommentForm/CommentForm'; -import { config } from '@config/website'; import { Comment as CommentData } from '@ts/types/comments'; +import { settings } from '@utils/config'; import { getFormattedDate } from '@utils/helpers/format'; import Head from 'next/head'; import Image from 'next/image'; @@ -23,7 +23,7 @@ const Comment = ({ }) => { const intl = useIntl(); const router = useRouter(); - const locale = router.locale ? router.locale : config.locales.defaultLocale; + const locale = router.locale ? router.locale : settings.locales.defaultLocale; const [isReply, setIsReply] = useState<boolean>(false); const firstFieldRef = useRef<HTMLInputElement>(null); @@ -146,12 +146,12 @@ const Comment = ({ const schemaJsonLd: WithContext<CommentSchema> = { '@context': 'https://schema.org', - '@id': `${config.url}/#comment-${comment.commentId}`, + '@id': `${settings.url}/#comment-${comment.commentId}`, '@type': 'Comment', parentItem: isNested - ? { '@id': `${config.url}/#comment-${comment.parentDatabaseId}` } + ? { '@id': `${settings.url}/#comment-${comment.parentDatabaseId}` } : undefined, - about: { '@type': 'Article', '@id': `${config.url}/#article` }, + about: { '@type': 'Article', '@id': `${settings.url}/#article` }, author: { '@type': 'Person', name: comment.author.name, diff --git a/src/components/Copyright/Copyright.tsx b/src/components/Copyright/Copyright.tsx index 9a57f9c..7ea3829 100644 --- a/src/components/Copyright/Copyright.tsx +++ b/src/components/Copyright/Copyright.tsx @@ -1,14 +1,14 @@ import { CopyrightIcon } from '@components/Icons'; -import { config } from '@config/website'; +import { settings } from '@utils/config'; import styles from './Copyright.module.scss'; const Copyright = () => { return ( <p className={styles.wrapper}> - <span>{config.name}</span> + <span>{settings.name}</span> <CopyrightIcon /> <span> - {config.copyright.startYear} - {config.copyright.endYear} + {settings.copyright.startYear} - {settings.copyright.endYear} </span> </p> ); diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index b479ef3..d074b68 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -2,7 +2,7 @@ import Footer from '@components/Footer/Footer'; import Header from '@components/Header/Header'; import Main from '@components/Main/Main'; import Breadcrumb from '@components/Breadcrumb/Breadcrumb'; -import { config } from '@config/website'; +import { settings } from '@utils/config'; import Head from 'next/head'; import { useRouter } from 'next/router'; import { ReactElement, ReactNode, useEffect, useRef } from 'react'; @@ -26,19 +26,19 @@ const Layout = ({ const schemaJsonLd: WithContext<WebSite> = { '@context': 'https://schema.org', - '@id': `${config.url}`, + '@id': `${settings.url}`, '@type': 'WebSite', - name: config.name, - description: config.baseline, - url: config.url, - author: { '@id': `${config.url}/#branding` }, - copyrightYear: Number(config.copyright.startYear), - creator: { '@id': `${config.url}/#branding` }, - editor: { '@id': `${config.url}/#branding` }, - inLanguage: config.locales.defaultLocale, + name: settings.name, + description: settings.baseline, + url: settings.url, + author: { '@id': `${settings.url}/#branding` }, + copyrightYear: Number(settings.copyright.startYear), + creator: { '@id': `${settings.url}/#branding` }, + editor: { '@id': `${settings.url}/#branding` }, + inLanguage: settings.locales.defaultLocale, potentialAction: { '@type': 'SearchAction', - target: `${config.url}/recherche?s={query}`, + target: `${settings.url}/recherche?s={query}`, query: 'required', }, }; @@ -46,14 +46,14 @@ const Layout = ({ return ( <> <Head> - <meta property="og:site_name" content={config.name} /> + <meta property="og:site_name" content={settings.name} /> <meta property="og:locale" - content={`${config.locales.defaultLocale}_${config.locales.defaultCountry}`} + content={`${settings.locales.defaultLocale}_${settings.locales.defaultCountry}`} /> <meta property="twitter:card" content="summary" /> - <meta property="twitter:site" content={config.twitterId} /> - <meta property="twitter:creator" content={config.twitterId} /> + <meta property="twitter:site" content={settings.twitterId} /> + <meta property="twitter:creator" content={settings.twitterId} /> <meta name="theme-color" content="#14578a" @@ -68,19 +68,19 @@ const Layout = ({ rel="alternate" href="/feed.xml" type="application/rss+xml" - title={`${config.name}'s RSS feed`} + title={`${settings.name}'s RSS feed`} /> <link rel="alternate" href="/atom.xml" type="application/atom+xml" - title={`${config.name}'s Atom feed`} + title={`${settings.name}'s Atom feed`} /> <link rel="alternate" href="/feed.json" type="application/feed+json" - title={`${config.name}'s Json feed`} + title={`${settings.name}'s Json feed`} /> <link rel="icon" href="/favicon.ico" sizes="any" /> <link rel="icon" href="/icon.svg" type="image/svg+xml" /> diff --git a/src/components/MDX/CodeBlock/CodeBlock.tsx b/src/components/MDX/CodeBlock/CodeBlock.tsx index 59386af..8311999 100644 --- a/src/components/MDX/CodeBlock/CodeBlock.tsx +++ b/src/components/MDX/CodeBlock/CodeBlock.tsx @@ -1,4 +1,4 @@ -import { config } from '@config/website'; +import { settings } from '@utils/config'; import { translateCopyButton } from '@utils/helpers/prism'; import { useRouter } from 'next/router'; import Prism from 'prismjs'; @@ -18,7 +18,7 @@ const CodeBlock = ({ ); const intl = useIntl(); const router = useRouter(); - const locale = router.locale ? router.locale : config.locales.defaultLocale; + const locale = router.locale ? router.locale : settings.locales.defaultLocale; useEffect(() => { Prism.highlightAll(); diff --git a/src/components/PostMeta/PostMeta.tsx b/src/components/PostMeta/PostMeta.tsx index 86e4e71..b951c44 100644 --- a/src/components/PostMeta/PostMeta.tsx +++ b/src/components/PostMeta/PostMeta.tsx @@ -1,5 +1,5 @@ -import { config } from '@config/website'; import { ArticleMeta } from '@ts/types/articles'; +import { settings } from '@utils/config'; import { getFormattedDate } from '@utils/helpers/format'; import Link from 'next/link'; import { useRouter } from 'next/router'; @@ -28,7 +28,7 @@ const PostMeta = ({ } = meta; const intl = useIntl(); const router = useRouter(); - const locale = router.locale ? router.locale : config.locales.defaultLocale; + const locale = router.locale ? router.locale : settings.locales.defaultLocale; const isThematic = () => router.asPath.includes('/thematique/'); const isArticle = () => router.asPath.includes('/article/'); diff --git a/src/components/PostPreview/PostPreview.tsx b/src/components/PostPreview/PostPreview.tsx index 72ba638..0be9709 100644 --- a/src/components/PostPreview/PostPreview.tsx +++ b/src/components/PostPreview/PostPreview.tsx @@ -1,9 +1,9 @@ import { ButtonLink } from '@components/Buttons'; import { ArrowIcon } from '@components/Icons'; import PostMeta from '@components/PostMeta/PostMeta'; -import { config } from '@config/website'; import { TitleLevel } from '@ts/types/app'; import { ArticleMeta, ArticlePreview } from '@ts/types/articles'; +import { settings } from '@utils/config'; import Image from 'next/image'; import Head from 'next/head'; import Link from 'next/link'; @@ -49,18 +49,18 @@ const PostPreview = ({ name: title, description: intro, articleBody: intro, - author: { '@id': `${config.url}/#branding` }, + author: { '@id': `${settings.url}/#branding` }, commentCount: commentCount ? commentCount : 0, copyrightYear: publicationDate.getFullYear(), - creator: { '@id': `${config.url}/#branding` }, + creator: { '@id': `${settings.url}/#branding` }, dateCreated: publicationDate.toISOString(), dateModified: updateDate.toISOString(), datePublished: publicationDate.toISOString(), - editor: { '@id': `${config.url}/#branding` }, + editor: { '@id': `${settings.url}/#branding` }, image: featuredImage?.sourceUrl, - inLanguage: config.locales.defaultLocale, - isBasedOn: `${config.url}/article/${slug}`, - isPartOf: { '@id': `${config.url}/blog` }, + inLanguage: settings.locales.defaultLocale, + isBasedOn: `${settings.url}/article/${slug}`, + isPartOf: { '@id': `${settings.url}/blog` }, license: 'https://creativecommons.org/licenses/by-sa/4.0/deed.fr', thumbnailUrl: featuredImage?.sourceUrl, }; diff --git a/src/components/ProjectSummary/ProjectSummary.tsx b/src/components/ProjectSummary/ProjectSummary.tsx index f2d73b6..03c9b87 100644 --- a/src/components/ProjectSummary/ProjectSummary.tsx +++ b/src/components/ProjectSummary/ProjectSummary.tsx @@ -1,11 +1,10 @@ import GithubIcon from '@assets/images/social-media/github.svg'; import GitlabIcon from '@assets/images/social-media/gitlab.svg'; -import { config } from '@config/website'; import { ProjectMeta } from '@ts/types/app'; +import { settings } from '@utils/config'; import { getFormattedDate } from '@utils/helpers/format'; import { slugify } from '@utils/helpers/slugify'; import useGithubApi from '@utils/hooks/useGithubApi'; -import IntlMessageFormat from 'intl-messageformat'; import Image from 'next/image'; import { useRouter } from 'next/router'; import { useIntl } from 'react-intl'; @@ -13,7 +12,6 @@ import styles from './ProjectSummary.module.scss'; const ProjectSummary = ({ id, - title, meta, }: { id: string; @@ -23,7 +21,7 @@ const ProjectSummary = ({ const { hasCover, license, repos, technologies } = meta; const intl = useIntl(); const router = useRouter(); - const locale = router.locale ? router.locale : config.locales.defaultLocale; + const locale = router.locale ? router.locale : settings.locales.defaultLocale; const { data } = useGithubApi(repos?.github ? repos.github : ''); return ( diff --git a/src/components/Widgets/RecentPosts/RecentPosts.tsx b/src/components/Widgets/RecentPosts/RecentPosts.tsx index 08ce7e4..1507edf 100644 --- a/src/components/Widgets/RecentPosts/RecentPosts.tsx +++ b/src/components/Widgets/RecentPosts/RecentPosts.tsx @@ -1,7 +1,7 @@ import Spinner from '@components/Spinner/Spinner'; -import { config } from '@config/website'; import { getPublishedPosts } from '@services/graphql/queries'; import { ArticlePreview } from '@ts/types/articles'; +import { settings } from '@utils/config'; import { getFormattedDate } from '@utils/helpers/format'; import Image from 'next/image'; import Link from 'next/link'; @@ -16,7 +16,7 @@ const RecentPosts = () => { getPublishedPosts({ first: 3 }) ); const router = useRouter(); - const locale = router.locale ? router.locale : config.locales.defaultLocale; + const locale = router.locale ? router.locale : settings.locales.defaultLocale; const getPost = (post: ArticlePreview) => { return ( |
