Skip to content

Commit

Permalink
Merge pull request #97 from devping-kr/chore/seo
Browse files Browse the repository at this point in the history
chore: google search console, GA 등록
  • Loading branch information
grapefruit13 authored Dec 30, 2024
2 parents a8c2f3d + 82d96b7 commit 62b6bd8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env*

# vercel
.vercel
Expand Down
28 changes: 28 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import type { Metadata } from 'next';
import './globals.css';
import localFont from 'next/font/local';
import Script from 'next/script';
import { env } from '@/lib/env';
import Providers from '@/contexts/Providers';
import { cn } from '@/utils/core';
import { ToastProvider } from '@/components/common/ToastProvider';
import { METADATA } from '@/constants/_metadata';

const { title, description, keywords, url, images } = METADATA;

const isProduction = process.env.NODE_ENV === 'production';
const GA_ID = env.GA_ID;

const pretendard = localFont({
src: '../../public/fonts/PretendardVariable.woff2',
display: 'swap',
Expand Down Expand Up @@ -39,6 +44,29 @@ export default function RootLayout({
}>) {
return (
<html lang='ko'>
<head>
<meta
name='google-site-verification'
content='cg79sBghjxaeDLPXXAtwcSeMFpbrwe6TVJQqjnFGAyI'
/>
{isProduction && GA_ID && (
<>
<Script
async
strategy='afterInteractive'
src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
></Script>
<Script id='google-analytics' strategy='afterInteractive'>
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`}
</Script>
</>
)}
</head>
<body className={cn('bg-white-100', pretendard.className)}>
<Providers>
<div>{children}</div>
Expand Down
Empty file removed src/hooks/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions src/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export const env = Object.freeze({
BASE_API_URL: `${process.env.NEXT_PUBLIC_BASE_API_URL}`,
QR_API_URL: `${process.env.NEXT_PUBLIC_QR_API_URL}`,
QR_APP_KEY: `${process.env.NEXT_PUBLIC_QR_APPKEY}`,
GA_ID: process.env.NEXT_PUBLIC_GA_ID,
});

0 comments on commit 62b6bd8

Please sign in to comment.