aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks/use-article.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-16 18:16:09 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-16 18:16:09 +0100
commitdcd2a7ab382fece8e0ae2979aad4a180b6a105e1 (patch)
tree0e58f8a5b4977eb0c9ff9759484ecded72bd7e38 /src/utils/hooks/use-article.tsx
parent4bdbca861293357bb7928c6c7a5990be9f37380b (diff)
build(components, hooks): fix type errors introduced by deps upgrade
Since #7e37f2b Typescript was complaining about some types.
Diffstat (limited to 'src/utils/hooks/use-article.tsx')
-rw-r--r--src/utils/hooks/use-article.tsx36
1 files changed, 0 insertions, 36 deletions
diff --git a/src/utils/hooks/use-article.tsx b/src/utils/hooks/use-article.tsx
deleted file mode 100644
index 86d8e38..0000000
--- a/src/utils/hooks/use-article.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import useSWR from 'swr';
-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 {UseArticleConfig} config - The config.
- * @returns {Article|undefined} The matching article if it exists.
- */
-export const useArticle = ({
- slug,
- fallback,
-}: UseArticleConfig): Article | undefined => {
- const { data } = useSWR(
- slug ? { query: articleBySlugQuery, variables: { slug } } : null,
- fetchAPI<RawArticle, typeof articleBySlugQuery>
- );
-
- return data ? getArticleFromRawData(data.post) : fallback;
-};