From 8f8f92b224705165550d09e4da45c32495c35a0b Mon Sep 17 00:00:00 2001 From: Mahdi Khashan <58775404+mahdikhashan@users.noreply.github.com> Date: Sat, 21 Jan 2023 16:04:35 +0330 Subject: [PATCH] refactor: move under src folder --- {src/hooks => hooks}/use-ninja.ts | 0 {src/lib => lib}/api.ts | 0 {src/lib => lib}/header.ts | 0 pages/404.tsx | 35 ++++++++ {src/pages => pages}/500.tsx | 0 {src/pages => pages}/_app.tsx | 0 {src/pages => pages}/_document.tsx | 0 {src/pages => pages}/about.tsx | 0 {src/pages => pages}/api/hello.ts | 0 {src/pages => pages}/blog/[slug].tsx | 0 {src/pages => pages}/index.tsx | 0 src/pages/404.tsx | 17 ---- src/ui/Header.tsx | 102 --------------------- {src/styles => styles}/globals.css | 0 tailwind.config.js | 4 +- tsconfig.json | 2 +- {src/ui => ui}/CustomLink.tsx | 0 {src/ui => ui}/ErrorBoundary.tsx | 0 {src/ui => ui}/Footer.tsx | 6 +- ui/Header.tsx | 127 +++++++++++++++++++++++++++ {src/ui => ui}/Info.tsx | 18 ++-- {src/ui => ui}/layouts/Default.tsx | 0 22 files changed, 177 insertions(+), 134 deletions(-) rename {src/hooks => hooks}/use-ninja.ts (100%) rename {src/lib => lib}/api.ts (100%) rename {src/lib => lib}/header.ts (100%) create mode 100644 pages/404.tsx rename {src/pages => pages}/500.tsx (100%) rename {src/pages => pages}/_app.tsx (100%) rename {src/pages => pages}/_document.tsx (100%) rename {src/pages => pages}/about.tsx (100%) rename {src/pages => pages}/api/hello.ts (100%) rename {src/pages => pages}/blog/[slug].tsx (100%) rename {src/pages => pages}/index.tsx (100%) delete mode 100644 src/pages/404.tsx delete mode 100644 src/ui/Header.tsx rename {src/styles => styles}/globals.css (100%) rename {src/ui => ui}/CustomLink.tsx (100%) rename {src/ui => ui}/ErrorBoundary.tsx (100%) rename {src/ui => ui}/Footer.tsx (88%) create mode 100644 ui/Header.tsx rename {src/ui => ui}/Info.tsx (55%) rename {src/ui => ui}/layouts/Default.tsx (100%) diff --git a/src/hooks/use-ninja.ts b/hooks/use-ninja.ts similarity index 100% rename from src/hooks/use-ninja.ts rename to hooks/use-ninja.ts diff --git a/src/lib/api.ts b/lib/api.ts similarity index 100% rename from src/lib/api.ts rename to lib/api.ts diff --git a/src/lib/header.ts b/lib/header.ts similarity index 100% rename from src/lib/header.ts rename to lib/header.ts diff --git a/pages/404.tsx b/pages/404.tsx new file mode 100644 index 0000000..98dced9 --- /dev/null +++ b/pages/404.tsx @@ -0,0 +1,35 @@ +/* eslint-disable react/no-unescaped-entities */ +import Head from 'next/head' +import Link from 'next/link' + +export default function Custom404() { + return ( + <> + + 404 | Mo Khashan + + + + +
+
+

+ 451 – Unavailable For Legal Reasons +

+

+ Why show a generic 404 when I can make it sound mysterious? It seems + you've found something that used to exist, or you spelled something + wrong. I'm guessing you spelled something wrong. Can you double check + that URL? +

+ + Return Home + +
+
+ + ) +} diff --git a/src/pages/500.tsx b/pages/500.tsx similarity index 100% rename from src/pages/500.tsx rename to pages/500.tsx diff --git a/src/pages/_app.tsx b/pages/_app.tsx similarity index 100% rename from src/pages/_app.tsx rename to pages/_app.tsx diff --git a/src/pages/_document.tsx b/pages/_document.tsx similarity index 100% rename from src/pages/_document.tsx rename to pages/_document.tsx diff --git a/src/pages/about.tsx b/pages/about.tsx similarity index 100% rename from src/pages/about.tsx rename to pages/about.tsx diff --git a/src/pages/api/hello.ts b/pages/api/hello.ts similarity index 100% rename from src/pages/api/hello.ts rename to pages/api/hello.ts diff --git a/src/pages/blog/[slug].tsx b/pages/blog/[slug].tsx similarity index 100% rename from src/pages/blog/[slug].tsx rename to pages/blog/[slug].tsx diff --git a/src/pages/index.tsx b/pages/index.tsx similarity index 100% rename from src/pages/index.tsx rename to pages/index.tsx diff --git a/src/pages/404.tsx b/src/pages/404.tsx deleted file mode 100644 index f525be5..0000000 --- a/src/pages/404.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import Head from 'next/head' - -export default function Custom404() { - return ( - <> - - 404 | Mo Khashan - - - - -
-

404 - Page Not Found

-
- - ) -} diff --git a/src/ui/Header.tsx b/src/ui/Header.tsx deleted file mode 100644 index 9eca64a..0000000 --- a/src/ui/Header.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { useState, useEffect } from 'react'; - -import { header } from '@/lib/header'; -import { Turn as Hamburger } from 'hamburger-react'; - -import clsx from 'clsx'; - -import { usePathname } from 'next/navigation'; - -import Link from 'next/link'; - -import { useTheme } from 'next-themes'; - -const ThemeSwitch = () => { - const [mounted, setMounted] = useState(false) - const { theme, setTheme } = useTheme() - - useEffect(() => { - setMounted(true) - }, []) - - if (!mounted) { - return null - } - - return ( - - ) -} - -export default function Header() { - const pathname = usePathname(); - const [isOpen, setOpen] = useState(false); - - return ( - <> -
-
setOpen(!isOpen)} - className={clsx( - "md:hidden !p-y-4 cursor-pointer fixed top-4", - "left-4 right-4 z-10 text-white bg-zinc-800 border-2 rounded-2xl", - { 'h-18 border-white text-white': !isOpen, 'border-orange-500 text-orange-500': isOpen }, - )}> -
- -
Menu
-
- {isOpen && header.map((link) => { - const isActive = link.slug === pathname - - return (!link?.isDisabled && - (
- - {link.name} - -
) - ); - })} -
-
- {header.map((link) => { - const isActive = link.slug === pathname - - return (!link?.isDisabled && - (
- { - - {link?.name} - {link?.redirect && - } - - } -
) - ); - })} -
-
- - ); - -} diff --git a/src/styles/globals.css b/styles/globals.css similarity index 100% rename from src/styles/globals.css rename to styles/globals.css diff --git a/tailwind.config.js b/tailwind.config.js index 9001457..672d039 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -3,11 +3,11 @@ module.exports = { important: true, darkMode: 'class', content: [ - "./src/**/*.{js,ts,jsx,tsx}", + "./**/*.{js,ts,jsx,tsx}", ], purge: { enabled: true, - content: ['./src/**/*.tsx'], + content: ['./**/*.tsx'], }, theme: { extend: { diff --git a/tsconfig.json b/tsconfig.json index 2159bf4..f4ab65f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "incremental": true, "baseUrl": ".", "paths": { - "@/*": ["./src/*"] + "@/*": ["./*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], diff --git a/src/ui/CustomLink.tsx b/ui/CustomLink.tsx similarity index 100% rename from src/ui/CustomLink.tsx rename to ui/CustomLink.tsx diff --git a/src/ui/ErrorBoundary.tsx b/ui/ErrorBoundary.tsx similarity index 100% rename from src/ui/ErrorBoundary.tsx rename to ui/ErrorBoundary.tsx diff --git a/src/ui/Footer.tsx b/ui/Footer.tsx similarity index 88% rename from src/ui/Footer.tsx rename to ui/Footer.tsx index de78036..d90708e 100644 --- a/src/ui/Footer.tsx +++ b/ui/Footer.tsx @@ -9,7 +9,7 @@ export default function Footer() { return ( <>
- {'©'}   {d.getFullYear()}   Mo Khashan. All Rights Reserved. + {'©'}   {d.getFullYear()}   Mohi Khashan. All Rights Reserved.