Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d6cfd2d

Browse files
Added GTAGs and updated README.
1 parent 3085e69 commit d6cfd2d

File tree

4 files changed

+64
-25
lines changed

4 files changed

+64
-25
lines changed

‎README.md‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1+
# ScuffedCode
2+
3+
This is Next.js clone of Leetcode with my solutions to some of Leetcode's questions.
4+
The data is hosted on Supabase PostgreSQL database and includes all the metadata included by Leetcode for each of 2500~ questions.
25

36
## Getting Started
47

5-
First, run the development server:
8+
### Setup the database
9+
10+
Visit [LeetCode-Scraper](https://github.com/nikhil-ravi/Leetcode-Scraper) to setup your own Supabase Database with leetcode questions and their associated metadata, and your solutions.
11+
12+
### Next.js Web Application
13+
14+
First, install the dependencies:
15+
16+
```bash
17+
npm i --legacy-peer-deps
18+
```
19+
20+
Setup your `.env.config` file:
21+
22+
```env
23+
NEXT_PUBLIC_SUPABASE_URL = <NEXT_PUBLIC_SUPABASE_URL>
24+
NEXT_PUBLIC_SUPABASE_KEY = <NEXT_PUBLIC_SUPABASE_KEY>
25+
```
26+
27+
Run the development server:
628

729
```bash
830
npm run dev
@@ -13,26 +35,3 @@ pnpm dev
1335
```
1436

1537
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16-
17-
You can start editing the page by modifying `app/page.jsx`. The page auto-updates as you edit the file.
18-
19-
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
20-
21-
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
22-
23-
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
24-
25-
## Learn More
26-
27-
To learn more about Next.js, take a look at the following resources:
28-
29-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
30-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
31-
32-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
33-
34-
## Deploy on Vercel
35-
36-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
37-
38-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

‎src/app/head.jsx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
import Script from "next/script";
2+
import * as gtag from "../lib/gtag";
3+
14
export default function Head() {
25
return (
36
<>
47
<title>ScuffedCode</title>
58
<meta content="width=device-width, initial-scale=1" name="viewport" />
69
<meta name="description" content="Generated by create next app" />
710
<link rel="icon" href="/favicon.ico" />
11+
<Script
12+
strategy="lazyOnload"
13+
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
14+
/>
15+
<Script
16+
id="gtag-init"
17+
strategy="lazyOnload"
18+
dangerouslySetInnerHTML={{
19+
__html: `
20+
window.dataLayer = window.dataLayer || [];
21+
function gtag(){dataLayer.push(arguments);}
22+
gtag('js', new Date());
23+
gtag('config', '${gtag.GA_TRACKING_ID}', {
24+
page_path: window.location.pathname,
25+
});
26+
`,
27+
}}
28+
/>
829
</>
930
);
1031
}

‎src/app/layout.jsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { SiGooglescholar } from "react-icons/si";
55
import { Providers } from "./Providers";
66

77
import { DarkModeButton } from "./DarkModeButton";
8+
import Head from "./head";
89
export default function RootLayout({ children }) {
910
return (
1011
<html lang="en">
12+
{/* <Head /> */}
1113
<body>
1214
<Providers>
1315
<main className="dark:bg-primary-800 min-h-screen px-10 flex-col overflow-y-scroll">

‎src/lib/gtag.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
2+
3+
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
4+
export const pageview = (url) => {
5+
window.gtag("config", GA_TRACKING_ID, {
6+
page_path: url,
7+
});
8+
};
9+
10+
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
11+
export const event = ({ action, category, label, value }) => {
12+
window.gtag("event", action, {
13+
event_category: category,
14+
event_label: label,
15+
value: value,
16+
});
17+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /