aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/index.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-20 16:38:54 +0200
committerArmand Philippot <git@armandphilippot.com>2023-09-20 16:38:54 +0200
commitf861e6a269ba9f62700776d3cd13b644a9e836d4 (patch)
treea5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/pages/index.tsx
parent03331c44276ec56e9f235e4d5ee75030455a753f (diff)
refactor: use named export for everything except pages
Next expect a default export for pages so only those components should use default exports. Everything else should use named exports to reduce the number of import statements.
Diffstat (limited to 'src/pages/index.tsx')
-rw-r--r--src/pages/index.tsx48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 291d011..8c357f1 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -2,30 +2,31 @@ import { MDXComponents } from 'mdx/types';
import { GetStaticProps } from 'next';
import Head from 'next/head';
import Script from 'next/script';
-import { ReactElement } from 'react';
+import { ReactNode, isValidElement } from 'react';
import { useIntl } from 'react-intl';
import FeedIcon from '../assets/images/icon-feed.svg';
-import ButtonLink from '../components/atoms/buttons/button-link';
-import Envelop from '../components/atoms/icons/envelop';
-import Column from '../components/atoms/layout/column';
-import Section, { type SectionProps } from '../components/atoms/layout/section';
-import List, { type ListItem } from '../components/atoms/lists/list';
-import ResponsiveImage from '../components/molecules/images/responsive-image';
-import Columns, {
- type ColumnsProps,
-} from '../components/molecules/layout/columns';
-import CardsList, {
+import {
+ ButtonLink,
+ CardsList,
type CardsListItem,
-} from '../components/organisms/layout/cards-list';
-import { getLayout } from '../components/templates/layout/layout';
+ Column,
+ Columns,
+ type ColumnsProps,
+ Envelop,
+ getLayout,
+ List,
+ type ListItem,
+ ResponsiveImage,
+ Section,
+ type SectionProps,
+} from '../components';
import HomePageContent from '../content/pages/homepage.mdx';
-import { getArticlesCard } from '../services/graphql/articles';
+import { getArticlesCard } from '../services/graphql';
import styles from '../styles/pages/home.module.scss';
-import { type ArticleCard, type NextPageWithLayout } from '../types/app';
-import { loadTranslation, type Messages } from '../utils/helpers/i18n';
-import { getSchemaJson, getWebPageSchema } from '../utils/helpers/schema-org';
-import useBreadcrumb from '../utils/hooks/use-breadcrumb';
-import useSettings from '../utils/hooks/use-settings';
+import { type ArticleCard, type NextPageWithLayout } from '../types';
+import { getSchemaJson, getWebPageSchema } from '../utils/helpers';
+import { loadTranslation, type Messages } from '../utils/helpers/server';
+import { useBreadcrumb, useSettings } from '../utils/hooks';
/**
* Retrieve a list of coding links.
@@ -259,25 +260,24 @@ const HomePage: NextPageWithLayout<HomeProps> = ({ recentPosts }) => {
* Create the page sections.
*
* @param {object} obj - An object containing the section body.
- * @param {ReactElement[]} obj.children - The section body.
+ * @param {ReactNode[]} obj.children - The section body.
* @returns {JSX.Element} A section element.
*/
const getSection = ({
children,
variant,
}: {
- children: ReactElement[];
+ children: ReactNode[];
variant: SectionProps['variant'];
}): JSX.Element => {
const [headingEl, ...content] = children;
- const title = headingEl.props.children;
return (
<Section
- title={title}
+ className={styles.section}
content={content}
+ title={isValidElement(headingEl) ? headingEl.props.children : ''}
variant={variant}
- className={styles.section}
/>
);
};