From f861e6a269ba9f62700776d3cd13b644a9e836d4 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 20 Sep 2023 16:38:54 +0200 Subject: 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. --- src/utils/hooks/use-article.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/utils/hooks/use-article.tsx') diff --git a/src/utils/hooks/use-article.tsx b/src/utils/hooks/use-article.tsx index f6512b2..86d8e38 100644 --- a/src/utils/hooks/use-article.tsx +++ b/src/utils/hooks/use-article.tsx @@ -1,23 +1,29 @@ import useSWR from 'swr'; -import { fetchAPI } from '../../services/graphql/api'; -import { getArticleFromRawData } from '../../services/graphql/articles'; -import { articleBySlugQuery } from '../../services/graphql/articles.query'; -import { Article } from '../../types/app'; -import { RawArticle } from '../../types/raw-data'; +import { + articleBySlugQuery, + fetchAPI, + getArticleFromRawData, +} from '../../services/graphql'; +import { type Article, type RawArticle } from '../../types'; export type UseArticleConfig = { + /** + * A fallback article + */ fallback?: Article; + /** + * The article slug + */ slug?: string; }; /** * Retrieve an article by slug. * - * @param {string} slug - The article slug. - * @param {Article} fallback - A fallback article. + * @param {UseArticleConfig} config - The config. * @returns {Article|undefined} The matching article if it exists. */ -const useArticle = ({ +export const useArticle = ({ slug, fallback, }: UseArticleConfig): Article | undefined => { @@ -28,5 +34,3 @@ const useArticle = ({ return data ? getArticleFromRawData(data.post) : fallback; }; - -export default useArticle; -- cgit v1.2.3