Skip to content

Commit

Permalink
refactor: NavigationSchemaScript 컴포넌트 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyugeon committed Jul 11, 2024
1 parent 98fa30f commit c081e23
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import type { Metadata } from 'next';

import {
appleSplashScreens,
navigationSchemaItems,
} from '@/constants/metadata';
import { appleSplashScreens } from '@/constants/metadata';

import GoogleAnalytics from '@/components/common/GoogleAnalytics';
import AuthFailedErrorBoundary from '@/components/common/AuthFailedErrorBoundary';
import PWAServiceWorkerProvider from '@/components/common/PWAServiceWorkerProvider';
import ReactQueryProvider from '@/components/common/ReactQueryProvider';
import ToastProvider from '@/components/common/Toast/ToastProvider';
import NavigationSchemaScript from '@/components/common/NavigationSchemaScript';
import Layout from '@/components/layout/Layout';

import { LineSeedKR } from '@/styles/font';
Expand Down Expand Up @@ -41,12 +39,6 @@ export const metadata: Metadata = {
},
};

const navigationSchema = {
'@context': 'https://schema.org',
'@type': 'ItemList',
itemListElement: navigationSchemaItems,
};

const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="ko">
Expand All @@ -61,10 +53,7 @@ const RootLayout = ({ children }: { children: React.ReactNode }) => {
</ReactQueryProvider>
</ToastProvider>
</PWAServiceWorkerProvider>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(navigationSchema) }}
/>
<NavigationSchemaScript />
</body>
</html>
);
Expand Down
21 changes: 21 additions & 0 deletions src/components/common/NavigationSchemaScript.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Script from 'next/script';

import { navigationSchemaItems } from '@/constants/metadata/schema';

const navigationSchema = {
'@context': 'https://schema.org',
'@type': 'ItemList',
itemListElement: navigationSchemaItems,
};

const NavigationSchemaScript = () => {
return (
<Script
id="navigation-schema"
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(navigationSchema) }}
/>
);
};

export default NavigationSchemaScript;

0 comments on commit c081e23

Please sign in to comment.