Skip to content

Commit

Permalink
refactor: useSiteMetadata 훅 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
doputer committed Feb 18, 2024
1 parent 0286ce5 commit 27bbfc5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
20 changes: 3 additions & 17 deletions src/components/comment.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
import { useEffect, useState } from 'react';

import Giscus from '@giscus/react';
import { graphql, useStaticQuery } from 'gatsby';

import useSiteMetadata from '@/hooks/useSiteMetadata';

export default function Comment() {
const {
site: { siteMetadata },
} = useStaticQuery(graphql`
query {
site {
siteMetadata {
comment {
repo
repoId
category
categoryId
}
}
}
}
`);
const siteMetadata = useSiteMetadata();
const [theme, setTheme] = useState('');

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import { MoonIcon, SunIcon } from '@heroicons/react/24/solid';
import { Link } from 'gatsby';

import Menu from '@/components/menu';
import useSiteMetadata from '@/hooks/useSiteMetadata';
import useTheme from '@/hooks/useTheme';

function Header() {
const siteMetadata = useSiteMetadata();
const [toggleTheme] = useTheme();
const links = ['About', 'Tags'];

return (
<header className="flex items-center justify-between">
<Link to="/" className="text-xl font-bold tracking-tight">
Doputer
{siteMetadata.title}
</Link>
<nav className="flex gap-4">
{links.map((link) => (
Expand Down
12 changes: 6 additions & 6 deletions src/components/seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ interface SEOProps {
}

function SEO({ title, description }: SEOProps) {
const seo = useSiteMetadata();
const siteMetadata = useSiteMetadata();

return (
<>
<html lang="ko" />
<title>{title || seo.title}</title>
<meta name="description" content={description || seo.description} />
<meta property="og:title" content={title || seo.title} />
<meta property="og:description" content={description || seo.description} />
<meta property="og:url" content={seo.siteUrl} />
<title>{title || siteMetadata.title}</title>
<meta name="description" content={description || siteMetadata.description} />
<meta property="og:title" content={title || siteMetadata.title} />
<meta property="og:description" content={description || siteMetadata.description} />
<meta property="og:url" content={siteMetadata.siteUrl} />
<meta name="naver-site-verification" content="ed40bb9e56fd7384da54f573c6dd780015474e61" />
</>
);
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useSiteMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const useSiteMetadata = () => {
title
description
siteUrl
comment {
repo
repoId
category
categoryId
}
}
}
}
Expand Down

0 comments on commit 27bbfc5

Please sign in to comment.