-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 구글 애널리틱스 추가 * feat: 사이트맵 작업 * feat: robots 파일 추가 * feat: metadata 작업 title, description 추가 og-image 추가 * chore: package 이름 변경 * chore: env 변경 * fix: 힌트 한글 엔터 입력시 2번 호출되는 에러 수정 nativeEvent.isComposing 이벤트 추가
- Loading branch information
Showing
12 changed files
with
143 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { cookies } from 'next/headers'; | ||
import { createClient } from '@/utils/supabase/server'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export async function GET( | ||
request: NextRequest, | ||
{ params }: { params: { id: string } } | ||
) { | ||
const { id } = params; | ||
|
||
const cookieStore = cookies(); | ||
const supabase = createClient(cookieStore); | ||
|
||
const { data: quiz } = await supabase | ||
.from('quizzes') | ||
.select('*') | ||
.eq('id', id) | ||
.limit(1) | ||
.single(); | ||
|
||
return NextResponse.json({ quiz }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { cookies } from 'next/headers'; | ||
import { createClient } from '@/utils/supabase/server'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
export async function GET() { | ||
const cookieStore = cookies(); | ||
const supabase = createClient(cookieStore); | ||
|
||
const { data: quizzes } = await supabase.from('quizzes').select('*'); | ||
|
||
return NextResponse.json({ quizzes }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client'; | ||
|
||
import Script from 'next/script'; | ||
import * as gtag from '../gtag.js'; | ||
|
||
const GoogleAnalytics = () => { | ||
return ( | ||
<> | ||
<Script | ||
strategy="afterInteractive" | ||
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`} | ||
/> | ||
<Script | ||
id="gtag-init" | ||
strategy="afterInteractive" | ||
dangerouslySetInnerHTML={{ | ||
__html: ` | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${gtag.GA_TRACKING_ID}', { | ||
page_path: window.location.pathname, | ||
}); | ||
`, | ||
}} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default GoogleAnalytics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { type MetadataRoute } from 'next'; | ||
|
||
async function getQuizzes(): Promise< | ||
Database['public']['Tables']['quizzes']['Row'][] | ||
> { | ||
const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/quizzes`); | ||
|
||
const { quizzes } = await res.json(); | ||
|
||
return quizzes; | ||
} | ||
|
||
export async function generateSitemaps() { | ||
const quizzes = await getQuizzes(); | ||
|
||
return quizzes.map((quiz) => ({ | ||
id: quiz.id, | ||
})); | ||
} | ||
export default async function sitemap({ | ||
id, | ||
}: { | ||
id: number; | ||
}): Promise<MetadataRoute.Sitemap> { | ||
const quizzes = await getQuizzes(); | ||
|
||
return quizzes.map((quiz) => ({ | ||
url: `${process.env.NEXT_PUBLIC_PROD_URL}/quizzes/${id}`, | ||
lastModified: quiz.updated_at, | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MetadataRoute } from 'next'; | ||
|
||
export default function robots(): MetadataRoute.Robots { | ||
return { | ||
rules: { | ||
userAgent: '*', | ||
allow: '/', | ||
disallow: '/private/', | ||
}, | ||
sitemap: `${process.env.NEXT_PUBLIC_PROD_URL}/sitemap.xml`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MetadataRoute } from 'next'; | ||
|
||
const PROD_URL = process.env.NEXT_PUBLIC_PROD_URL; | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
return [ | ||
{ | ||
url: `${PROD_URL}`, | ||
lastModified: new Date(), | ||
changeFrequency: 'yearly', | ||
priority: 1, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GOOGLE_ID; | ||
|
||
export const pageview = (url) => { | ||
window.gtag('config', GA_TRACKING_ID, { | ||
page_path: url, | ||
}); | ||
}; | ||
|
||
export const event = ({ action, category, label, value }) => { | ||
window.gtag('event', action, { | ||
event_category: category, | ||
event_label: label, | ||
value: value, | ||
}); | ||
}; |