Commit fb69445b by Madhankumar

initial commit

parents
{
"extends": "next/core-web-vitals"
}
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
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).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
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.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
import React from "react";
const AboutLayout = ({ children }) => {
return <div>{children}</div>;
};
export default AboutLayout;
import React from "react";
export const metadata = {
title: "About",
};
const About = () => {
return (
<div>
<h1>About</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque
vitae scelerisque arcu. Nulla turpis nunc, aliquet non elementum
fermentum, feugiat eu elit. Sed vel varius augue. Aliquam mollis velit
at magna sollicitudin, at pulvinar enim euismod. Vestibulum sit amet
iaculis magna. Mauris malesuada finibus blandit. Pellentesque ac auctor
erat. Phasellus rutrum auctor nisl ac semper.
</p>
</div>
);
};
export default About;
import React from "react";
const Team = () => {
return (
<div>
<h1>Our Team</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque
vitae scelerisque arcu. Nulla turpis nunc, aliquet non elementum
fermentum, feugiat eu elit. Sed vel varius augue. Aliquam mollis velit
at magna sollicitudin, at pulvinar enim euismod. Vestibulum sit amet
iaculis magna. Mauris malesuada finibus blandit. Pellentesque ac auctor
erat. Phasellus rutrum auctor nisl ac semper.
</p>
</div>
);
};
export default Team;
[
{
"id": 1,
"title": "React Front To Back",
"description": "Learn Modern React, Including Hooks, Context API, Full Stack MERN & Redux By Building Real Life Projects.",
"link": "https://www.traversymedia.com/Modern-React-Front-To-Back-Course",
"level": "Beginner"
},
{
"id": 2,
"title": "Node.js API Masterclass",
"description": "Build an extensive RESTful API using Node.js, Express, and MongoDB",
"link": "https://www.traversymedia.com/node-js-api-masterclass",
"level": "Intermediate"
},
{
"id": 3,
"title": "Modern JavaScript From The Beginning",
"description": "37 hour course that teaches you all of the fundamentals of modern JavaScript.",
"link": "https://www.traversymedia.com/modern-javascript-2-0",
"level": "All Levels"
},
{
"id": 4,
"title": "Next.js Dev To Deployment",
"description": "Learn Next.js by building a music event website and a web dev blog as a static website",
"link": "https://www.traversymedia.com/next-js-dev-to-deployment",
"level": "Intermediate"
},
{
"id": 5,
"title": "50 Projects in 50 Days",
"description": "Sharpen your skills by building 50 quick, unique & fun mini projects.",
"link": "https://www.traversymedia.com/50-Projects-In-50-Days",
"level": "Beginner"
}
]
\ No newline at end of file
import courses from "./data.json";
import { NextResponse } from "next/server";
export async function GET() {
return NextResponse.json(courses);
}
import { NextResponse } from "next/server";
import courses from "../data.json";
export async function GET(request) {
const { searchParams } = new URL(request.url);
const query = searchParams.get("query");
const filterCourse = courses.filter((e) => {
return e.title.toLowerCase().includes(query.toLowerCase());
});
return NextResponse.json(filterCourse);
}
export async function GET(req) {
return new Response("hello");
}
.repo-card {
background: #fff;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
padding: 1.5rem;
margin: 1rem;
}
.btn {
background: #f4f4f4;
border-radius: 5px;
list-style: none;
text-decoration: none;
color: black;
padding: 0.4em 0.8em;
}
.btn:hover {
background: #065fd4;
color: #fff;
}
import { ReposComponent } from "@/app/components/Repos/page";
import { ReposDirComponent } from "@/app/components/ReposDir/page";
import Link from "next/link";
import styles from "./[name].module.css";
import { Suspense } from "react";
const page = ({ params: { name } }) => {
return (
<div className={styles["repo-card"]}>
<Link href="/code/repos" className={styles.btn}>
Back To Repositories
</Link>
<Suspense fallback={<h3>Loading repo...</h3>}>
<ReposComponent name={name} />
</Suspense>
<Suspense fallback={<h3>Loading dir...</h3>}>
<ReposDirComponent name={name} />
</Suspense>
</div>
);
};
export default page;
import Link from "next/link";
import styles from "./repos.module.css";
import { FaStar, FaCodeBranch, FaEye } from "react-icons/fa";
async function fetchRepos() {
const response = await fetch(
"https://api.github.com/users/bradtraversy/repos",
{
next: {
revalidate: 100, //after 100sec
},
}
);
await new Promise((resolve) => setTimeout(resolve, 1000));
return await response.json();
}
const Repos = async () => {
const repos = await fetchRepos();
return (
<div className={styles["repo-container"]}>
<h1>Repositories</h1>
<ul className={styles["repo-list"]}>
{repos.map((e, i) => (
<li key={i}>
<Link href={`/code/repos/${e.name}`}>
<h3>{e.name}</h3>
<p>{e.description}</p>
<div className={styles["icons"]}>
<span>
<FaStar />
{e.stargazers_count}
</span>
<span>
<FaCodeBranch />
{e.forks_count}
</span>
<span>
<FaEye />
{e.watchers_count}
</span>
</div>
</Link>
</li>
))}
</ul>
</div>
);
};
export default Repos;
.repo-list {
list-style: none;
padding: 1rem;
}
.repo-list li {
background: #fff;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
padding: 1rem;
margin-bottom: 1em;
}
.repo-list li a {
text-decoration: none;
color: black;
}
.icons {
display: flex;
justify-content: space-between;
}
.repo-container h1 {
padding-left: 0.5em;
}
.form {
display: flex;
gap: 1em;
margin-top: 1em;
padding: 1em 1em 0em;
}
.form input {
padding: 0.8em;
width: 100%;
outline: none;
border: 2px solid #f4f4f4;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
font-size: 18px;
}
.form button {
background-color: #065fd4;
color: white;
padding: 1em 2em;
outline: none;
border: none;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}
"use client";
import styles from "./CourseSearch.module.css";
import { useState } from "react";
const CourseSearch = ({ getCourseResponse }) => {
const [query, setQuery] = useState("");
const handleSubmit = async (e) => {
e.preventDefault();
const response = await fetch(
`http://localhost:3000/api/courses/search?query=${query}`
);
const data = await response.json();
getCourseResponse(data);
};
return (
<form onSubmit={handleSubmit} className={styles["form"]}>
<input
type="text"
value={query}
placeholder="Search"
onChange={(e) => setQuery(e.target.value)}
/>
<button type="submit">Search</button>
</form>
);
};
export default CourseSearch;
.card {
background: #fff;
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
padding: 1.5rem;
margin: 1.4rem 1rem;
}
.btn {
background: #065fd4;
border-radius: 5px;
list-style: none;
text-decoration: none;
color: #fff;
padding: 0.4em 0.8em;
}
.container {
padding: 1rem 0;
}
import Link from "next/link";
import styles from "./Courses.module.css";
const Courses = ({ courses }) => {
return (
<div className={styles.container}>
{courses?.map((e, i) => (
<div key={i} className={styles["card"]}>
<h2>{e.title}</h2>
<small>Level:{e.level}</small>
<p>{e.description}</p>
<Link href={e.link} target="_blank" className={styles["btn"]}>
Go To Course
</Link>
</div>
))}
</div>
);
};
export default Courses;
.header {
background: #065fd4;
color: #fff;
text-align: center;
padding: 0.5em;
}
.links ul li {
list-style: none;
display: inline-block;
margin-right: 2em;
}
.links ul li a {
text-decoration: none;
font-size: 18px;
color: white;
}
.logo {
text-decoration: none;
color: white;
}
import Link from "next/link";
import styles from "./Header.module.css";
const Header = () => {
return (
<header className={styles.header}>
<Link href="/" className={styles.logo}>
<h1>Traversy Media</h1>
</Link>
<div className={styles.links}>
<ul>
<li>
<Link href="/about">About</Link>
</li>
<li>
<Link href="/about/team">Our Team</Link>
</li>
<li>
<Link href="/code/repos">Code</Link>
</li>
</ul>
</div>
</header>
);
};
export default Header;
.repo-count {
display: flex;
justify-content: space-between;
}
import { FaStar, FaCodeBranch, FaEye } from "react-icons/fa";
import styles from "./Repos.module.css";
async function fetchRepoByName(name) {
const response = await fetch(
`https://api.github.com/repos/bradtraversy/${name}`
);
return await response.json();
}
export const ReposComponent = async ({ name }) => {
const repos = await fetchRepoByName(name);
return (
<div>
<h2>{repos.name}</h2>
<p>{repos.description}</p>
<div className={styles["repo-count"]}>
<span>
<FaStar />
{repos.stargazers_count}
</span>
<span>
<FaCodeBranch />
{repos.forks_count}
</span>
<span>
<FaEye />
{repos.watchers_count}
</span>
</div>
</div>
);
};
import Link from "next/link";
import styles from "./ReposDir.module.css";
async function fetchRepoContent(name) {
const response = await fetch(
`https://api.github.com/repos/bradtraversy/${name}/contents`
);
await new Promise((resolve) => setTimeout(resolve, 2000));
return await response.json();
}
export const ReposDirComponent = async ({ name }) => {
const contents = await fetchRepoContent(name);
const dirs = await contents.filter((content) => content.type === "dir");
return (
<>
<h3>Directories</h3>
<ul className={styles.list}>
{dirs.map((e) => (
<li key={e.path}>
<Link href={`/code/repos/${name}/${e.path}`}>{e.path}</Link>
</li>
))}
</ul>
</>
);
};
File added
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1100px;
margin: 0 auto;
}
.loader {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
border-left-color: blue;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.error {
text-align: center;
}
import { Inter } from "next/font/google";
import "./globals.css";
import Header from "./components/Header/page";
import { Poppins } from "next/font/google";
const inter = Inter({ subsets: ["latin"] });
const poppins = Poppins({
weight: ["400", "700"],
subsets: ["latin"],
});
export const metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={poppins.className}>
<Header />
<div className="container">{children}</div>
</body>
</html>
);
}
const Loading = () => {
return (
<div className="loader">
<div className="spinner"></div>
</div>
);
};
export default Loading;
import React from "react";
const PageNotFound = () => {
return (
<div className="error">
<h1>404</h1>
<h4>Page Not Found</h4>
</div>
);
};
export default PageNotFound;
"use client";
import Courses from "./components/Courses/page";
import { useState, useEffect } from "react";
import Loading from "./loading";
import CourseSearch from "./components/CourseSearch/page";
const Home = () => {
const [courses, setCourses] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchCourses = async () => {
const response = await fetch("http://localhost:3000/api/courses");
const data = await response.json();
setCourses(data);
setLoading(false);
};
fetchCourses();
}, []);
if (loading) {
return <Loading />;
}
return (
<>
<CourseSearch getCourseResponse={(result) => setCourses(result)} />
<Courses courses={courses} />
</>
);
};
export default Home;
.main {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
padding: 6rem;
min-height: 100vh;
}
.description {
display: inherit;
justify-content: inherit;
align-items: inherit;
font-size: 0.85rem;
max-width: var(--max-width);
width: 100%;
z-index: 2;
font-family: var(--font-mono);
}
.description a {
display: flex;
justify-content: center;
align-items: center;
gap: 0.5rem;
}
.description p {
position: relative;
margin: 0;
padding: 1rem;
background-color: rgba(var(--callout-rgb), 0.5);
border: 1px solid rgba(var(--callout-border-rgb), 0.3);
border-radius: var(--border-radius);
}
.code {
font-weight: 700;
font-family: var(--font-mono);
}
.grid {
display: grid;
grid-template-columns: repeat(4, minmax(25%, auto));
max-width: 100%;
width: var(--max-width);
}
.card {
padding: 1rem 1.2rem;
border-radius: var(--border-radius);
background: rgba(var(--card-rgb), 0);
border: 1px solid rgba(var(--card-border-rgb), 0);
transition: background 200ms, border 200ms;
}
.card span {
display: inline-block;
transition: transform 200ms;
}
.card h2 {
font-weight: 600;
margin-bottom: 0.7rem;
}
.card p {
margin: 0;
opacity: 0.6;
font-size: 0.9rem;
line-height: 1.5;
max-width: 30ch;
}
.center {
display: flex;
justify-content: center;
align-items: center;
position: relative;
padding: 4rem 0;
}
.center::before {
background: var(--secondary-glow);
border-radius: 50%;
width: 480px;
height: 360px;
margin-left: -400px;
}
.center::after {
background: var(--primary-glow);
width: 240px;
height: 180px;
z-index: -1;
}
.center::before,
.center::after {
content: '';
left: 50%;
position: absolute;
filter: blur(45px);
transform: translateZ(0);
}
.logo {
position: relative;
}
/* Enable hover only on non-touch devices */
@media (hover: hover) and (pointer: fine) {
.card:hover {
background: rgba(var(--card-rgb), 0.1);
border: 1px solid rgba(var(--card-border-rgb), 0.15);
}
.card:hover span {
transform: translateX(4px);
}
}
@media (prefers-reduced-motion) {
.card:hover span {
transform: none;
}
}
/* Mobile */
@media (max-width: 700px) {
.content {
padding: 4rem;
}
.grid {
grid-template-columns: 1fr;
margin-bottom: 120px;
max-width: 320px;
text-align: center;
}
.card {
padding: 1rem 2.5rem;
}
.card h2 {
margin-bottom: 0.5rem;
}
.center {
padding: 8rem 0 6rem;
}
.center::before {
transform: none;
height: 300px;
}
.description {
font-size: 0.8rem;
}
.description a {
padding: 1rem;
}
.description p,
.description div {
display: flex;
justify-content: center;
position: fixed;
width: 100%;
}
.description p {
align-items: center;
inset: 0 0 auto;
padding: 2rem 1rem 1.4rem;
border-radius: 0;
border: none;
border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.25);
background: linear-gradient(
to bottom,
rgba(var(--background-start-rgb), 1),
rgba(var(--callout-rgb), 0.5)
);
background-clip: padding-box;
backdrop-filter: blur(24px);
}
.description div {
align-items: flex-end;
pointer-events: none;
inset: auto 0 0;
padding: 2rem;
height: 200px;
background: linear-gradient(
to bottom,
transparent 0%,
rgb(var(--background-end-rgb)) 40%
);
z-index: 1;
}
}
/* Tablet and Smaller Desktop */
@media (min-width: 701px) and (max-width: 1120px) {
.grid {
grid-template-columns: repeat(2, 50%);
}
}
@media (prefers-color-scheme: dark) {
.vercelLogo {
filter: invert(1);
}
.logo {
filter: invert(1) drop-shadow(0 0 0.3rem #ffffff70);
}
}
@keyframes rotate {
from {
transform: rotate(360deg);
}
to {
transform: rotate(0deg);
}
}
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
/** @type {import('next').NextConfig} */
const nextConfig = {}
module.exports = nextConfig
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "simple-blog",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "14.0.1",
"react": "^18",
"react-dom": "^18",
"react-icons": "^4.11.0"
},
"devDependencies": {
"eslint": "^8",
"eslint-config-next": "14.0.1"
}
}
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment