Skip to content

Commit 8013fe4

Browse files
committed
feat: GA 및 조회수 API 추가
1 parent 14a95d7 commit 8013fe4

5 files changed

Lines changed: 180 additions & 149 deletions

File tree

app/api/view/route.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export async function POST(request: Request) {
2+
const { category, slug } = await request.json();
3+
4+
await fetch(
5+
`https://blog-server.un-defined.dev/posts/${category}/${slug}/view`,
6+
{
7+
method: "POST",
8+
},
9+
);
10+
11+
return Response.json({ message: "success" });
12+
}

app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import "./globals.css";
22

3+
import { GoogleAnalytics } from "@next/third-parties/google";
34
import type { Metadata } from "next";
45
import { Geist, Geist_Mono } from "next/font/google";
56

@@ -74,6 +75,7 @@ export default async function RootLayout({
7475
<MobileBottomTab />
7576
</div>
7677
</ThemeProvider>
78+
<GoogleAnalytics gaId={"G-HT07LQYBG3"} />
7779
</body>
7880
</html>
7981
);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"docker:run": "docker run -p 3000:3000 undefined-dev"
1414
},
1515
"dependencies": {
16+
"@next/third-parties": "^16.1.6",
1617
"class-variance-authority": "^0.7.1",
1718
"clsx": "^2.1.1",
1819
"dayjs": "^1.11.19",

0 commit comments

Comments
 (0)