diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-09-20 16:38:54 +0200 |
| commit | f861e6a269ba9f62700776d3cd13b644a9e836d4 (patch) | |
| tree | a5a107e7a6e4ff8b4261fe04349357bc00b783ee /src/utils/hooks/use-article.tsx | |
| parent | 03331c44276ec56e9f235e4d5ee75030455a753f (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/utils/hooks/use-article.tsx')
| -rw-r--r-- | src/utils/hooks/use-article.tsx | 24 |
1 files changed, 14 insertions, 10 deletions
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; |
