From 2cb80a42ae0a3ba22e19d1b18ae5b86beb4773d9 Mon Sep 17 00:00:00 2001 From: DefectingCat Date: Thu, 17 Aug 2023 17:15:46 +0800 Subject: [PATCH] refactor app struct --- app/blog/[page]/page.tsx | 4 ++-- app/blog/loading.tsx | 2 +- app/blog/page.tsx | 6 +++--- app/g/[id]/page.tsx | 4 +--- app/g/loading.tsx | 2 +- app/gists/[page]/page.tsx | 4 ++-- app/gists/layout.tsx | 4 ++-- app/gists/loading.tsx | 2 +- app/gists/page.tsx | 4 ++-- app/layout.tsx | 6 +++--- app/page.tsx | 2 +- app/projects/loading.tsx | 4 ++-- app/projects/page.tsx | 8 ++++++-- components/models/cat-model.tsx | 6 +++--- {app => components/pages}/blog/post-card-loading.tsx | 0 {app => components/pages}/blog/post-card.tsx | 0 {app => components/pages}/dark-mode-btn.tsx | 0 {app => components/pages}/footer.tsx | 0 {app => components/pages}/gists/file-content-skeleton.tsx | 0 {app => components/pages}/gists/file-content.tsx | 2 +- {app => components/pages}/gists/gists-code-skeleton.tsx | 0 {app => components/pages}/gists/gists-code.module.css | 0 {app => components/pages}/gists/gists-code.tsx | 0 {app => components/pages}/gists/gists-skeleton.tsx | 0 {app => components/pages}/gists/user-info-skeleton.tsx | 0 {app => components/pages}/gists/user-info.tsx | 0 {app => components/pages}/nav-bar.tsx | 0 {app => components/pages}/projects/content.tsx | 0 .../pages}/projects/project-card-skeleton.tsx | 0 {app => components/pages}/projects/project-card.tsx | 0 {app => components/pages}/theme-provider.tsx | 0 31 files changed, 31 insertions(+), 29 deletions(-) rename {app => components/pages}/blog/post-card-loading.tsx (100%) rename {app => components/pages}/blog/post-card.tsx (100%) rename {app => components/pages}/dark-mode-btn.tsx (100%) rename {app => components/pages}/footer.tsx (100%) rename {app => components/pages}/gists/file-content-skeleton.tsx (100%) rename {app => components/pages}/gists/file-content.tsx (100%) rename {app => components/pages}/gists/gists-code-skeleton.tsx (100%) rename {app => components/pages}/gists/gists-code.module.css (100%) rename {app => components/pages}/gists/gists-code.tsx (100%) rename {app => components/pages}/gists/gists-skeleton.tsx (100%) rename {app => components/pages}/gists/user-info-skeleton.tsx (100%) rename {app => components/pages}/gists/user-info.tsx (100%) rename {app => components/pages}/nav-bar.tsx (100%) rename {app => components/pages}/projects/content.tsx (100%) rename {app => components/pages}/projects/project-card-skeleton.tsx (100%) rename {app => components/pages}/projects/project-card.tsx (100%) rename {app => components/pages}/theme-provider.tsx (100%) diff --git a/app/blog/[page]/page.tsx b/app/blog/[page]/page.tsx index fc5ff54..0ae9a4c 100644 --- a/app/blog/[page]/page.tsx +++ b/app/blog/[page]/page.tsx @@ -1,5 +1,5 @@ -import PostCard from 'app/blog/post-card'; -import PostCardLoading from 'app/blog/post-card-loading'; +import PostCard from 'components/pages/blog/post-card'; +import PostCardLoading from 'components/pages/blog/post-card-loading'; import Pagination from 'components/rua/rua-pagination'; import { getPostListPath, postLists, PostPerPage } from 'lib/posts'; import { notFound } from 'next/navigation'; diff --git a/app/blog/loading.tsx b/app/blog/loading.tsx index 624c120..ede66fd 100644 --- a/app/blog/loading.tsx +++ b/app/blog/loading.tsx @@ -1,4 +1,4 @@ -import PostCardLoading from './post-card-loading'; +import PostCardLoading from 'components/pages/blog/post-card-loading'; const Loading = () => { const num = Array(4).fill(1); diff --git a/app/blog/page.tsx b/app/blog/page.tsx index 2bfa057..456e5ab 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -1,8 +1,8 @@ -import PostCard from './post-card'; -import PostCardLoading from './post-card-loading'; +import PostCard from 'components/pages/blog/post-card'; +import PostCardLoading from 'components/pages/blog/post-card-loading'; +import Pagination from 'components/rua/rua-pagination'; import { PostPerPage, postLists } from 'lib/posts'; import { Fragment, Suspense } from 'react'; -import Pagination from 'components/rua/rua-pagination'; export default async function Page() { const allPosts = await postLists(); diff --git a/app/g/[id]/page.tsx b/app/g/[id]/page.tsx index a416525..0ed42fb 100644 --- a/app/g/[id]/page.tsx +++ b/app/g/[id]/page.tsx @@ -1,6 +1,5 @@ -import GistsCode from 'app/gists/gists-code'; -import clsx from 'clsx'; import LinkAnchor from 'components/mdx/link-anchor'; +import GistsCode from 'components/pages/gists/gists-code'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import { getSignalGist } from 'lib/fetcher'; @@ -8,7 +7,6 @@ import Image from 'next/image'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import avatar from 'public/images/img/avatar.svg'; -import GistsCodeSkeleton from 'app/gists/gists-code-skeleton'; export const revalidate = 600; diff --git a/app/g/loading.tsx b/app/g/loading.tsx index 9f14e63..eb37834 100644 --- a/app/g/loading.tsx +++ b/app/g/loading.tsx @@ -1,4 +1,4 @@ -import GistsCodeSkeleton from 'app/gists/gists-code-skeleton'; +import GistsCodeSkeleton from 'components/pages/gists/gists-code-skeleton'; import clsx from 'clsx'; const loading = () => { diff --git a/app/gists/[page]/page.tsx b/app/gists/[page]/page.tsx index bf2c9d6..812e3fe 100644 --- a/app/gists/[page]/page.tsx +++ b/app/gists/[page]/page.tsx @@ -1,7 +1,7 @@ +import FileContent from 'components/pages/gists/file-content'; +import Pagination from 'components/rua/rua-pagination'; import { getGists } from 'lib/fetcher'; import { notFound } from 'next/navigation'; -import FileContent from '../file-content'; -import Pagination from 'components/rua/rua-pagination'; export const revalidate = 600; diff --git a/app/gists/layout.tsx b/app/gists/layout.tsx index 7168582..560fc3c 100644 --- a/app/gists/layout.tsx +++ b/app/gists/layout.tsx @@ -1,7 +1,7 @@ +import UserInfo from 'components/pages/gists/user-info'; +import UserInfoLoading from 'components/pages/gists/user-info-skeleton'; import { Metadata } from 'next'; import { ReactNode, Suspense } from 'react'; -import UserInfo from './user-info'; -import UserInfoLoading from './user-info-skeleton'; export const revalidate = 600; export const metadata: Metadata = { diff --git a/app/gists/loading.tsx b/app/gists/loading.tsx index 744a9fe..bb211d4 100644 --- a/app/gists/loading.tsx +++ b/app/gists/loading.tsx @@ -1,4 +1,4 @@ -import FileContentLoading from './file-content-skeleton'; +import FileContentLoading from 'components/pages/gists/file-content-skeleton'; export default function Loading() { const num = Array(3).fill(null); diff --git a/app/gists/page.tsx b/app/gists/page.tsx index 04fe5b4..459073c 100644 --- a/app/gists/page.tsx +++ b/app/gists/page.tsx @@ -1,7 +1,7 @@ +import FileContent from 'components/pages/gists/file-content'; +import Pagination from 'components/rua/rua-pagination'; import { getGists } from 'lib/fetcher'; import { notFound } from 'next/navigation'; -import Pagination from 'components/rua/rua-pagination'; -import FileContent from './file-content'; export const revalidate = 600; diff --git a/app/layout.tsx b/app/layout.tsx index 9ae2bd8..111ddab 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,15 +1,15 @@ import '@docsearch/css/dist/style.css'; import clsx from 'clsx'; import BackToTop from 'components/common/back-to-top'; +import Footer from 'components/pages/footer'; +import HeadBar from 'components/pages/nav-bar'; +import RUAThemeProvider from 'components/pages/theme-provider'; import fonts from 'lib/fonts'; import { Metadata } from 'next'; import 'styles/globals.css'; import 'styles/prism-one-dark.css'; import 'styles/prism-one-light.css'; import 'styles/rua.css'; -import Footer from './footer'; -import HeadBar from './nav-bar'; -import RUAThemeProvider from './theme-provider'; export const metadata: Metadata = { title: 'RUA', diff --git a/app/page.tsx b/app/page.tsx index cb47d5b..4f32ad8 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx'; +import dynamic from 'next/dynamic'; import Image from 'next/image'; import styles from 'styles/index/index.module.css'; -import dynamic from 'next/dynamic'; const HomeModel = dynamic(() => import('../components/models/home-model')); diff --git a/app/projects/loading.tsx b/app/projects/loading.tsx index 2a4a0c4..388344c 100644 --- a/app/projects/loading.tsx +++ b/app/projects/loading.tsx @@ -1,7 +1,7 @@ import clsx from 'clsx'; +import { projects, selfHosts } from 'components/pages/projects/content'; +import PojectCardSkeleton from 'components/pages/projects/project-card-skeleton'; import { Metadata } from 'next'; -import { projects, selfHosts } from './content'; -import PojectCardSkeleton from './project-card-skeleton'; export const metadata: Metadata = { title: 'RUA - Projects', diff --git a/app/projects/page.tsx b/app/projects/page.tsx index 2d8f89d..63ed488 100644 --- a/app/projects/page.tsx +++ b/app/projects/page.tsx @@ -1,7 +1,11 @@ import clsx from 'clsx'; -import ProjectCard from './project-card'; +import { + iconMap, + projects, + selfHosts, +} from 'components/pages/projects/content'; +import ProjectCard from 'components/pages/projects/project-card'; import { Metadata } from 'next'; -import { projects, iconMap, selfHosts } from './content'; export const metadata: Metadata = { title: 'RUA - Projects', diff --git a/components/models/cat-model.tsx b/components/models/cat-model.tsx index ed59a14..295ffde 100644 --- a/components/models/cat-model.tsx +++ b/components/models/cat-model.tsx @@ -1,10 +1,10 @@ -import { useThree, useLoader, useFrame } from '@react-three/fiber'; +import { useFrame, useLoader, useThree } from '@react-three/fiber'; import { getMousePosition } from 'lib/utils'; -import { useRef, useEffect } from 'react'; +import { useEffect, useRef } from 'react'; +import useStore from 'store'; import * as THREE from 'three'; import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; -import useStore from 'store'; import { rotationX, rotationY } from './home-model'; const CatModel = () => { diff --git a/app/blog/post-card-loading.tsx b/components/pages/blog/post-card-loading.tsx similarity index 100% rename from app/blog/post-card-loading.tsx rename to components/pages/blog/post-card-loading.tsx diff --git a/app/blog/post-card.tsx b/components/pages/blog/post-card.tsx similarity index 100% rename from app/blog/post-card.tsx rename to components/pages/blog/post-card.tsx diff --git a/app/dark-mode-btn.tsx b/components/pages/dark-mode-btn.tsx similarity index 100% rename from app/dark-mode-btn.tsx rename to components/pages/dark-mode-btn.tsx diff --git a/app/footer.tsx b/components/pages/footer.tsx similarity index 100% rename from app/footer.tsx rename to components/pages/footer.tsx diff --git a/app/gists/file-content-skeleton.tsx b/components/pages/gists/file-content-skeleton.tsx similarity index 100% rename from app/gists/file-content-skeleton.tsx rename to components/pages/gists/file-content-skeleton.tsx diff --git a/app/gists/file-content.tsx b/components/pages/gists/file-content.tsx similarity index 100% rename from app/gists/file-content.tsx rename to components/pages/gists/file-content.tsx index e609b81..c1e84c1 100644 --- a/app/gists/file-content.tsx +++ b/components/pages/gists/file-content.tsx @@ -3,8 +3,8 @@ import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import Link from 'next/link'; import { memo } from 'react'; -import GistsCode from './gists-code'; import { GistData } from 'types'; +import GistsCode from './gists-code'; dayjs.extend(relativeTime); diff --git a/app/gists/gists-code-skeleton.tsx b/components/pages/gists/gists-code-skeleton.tsx similarity index 100% rename from app/gists/gists-code-skeleton.tsx rename to components/pages/gists/gists-code-skeleton.tsx diff --git a/app/gists/gists-code.module.css b/components/pages/gists/gists-code.module.css similarity index 100% rename from app/gists/gists-code.module.css rename to components/pages/gists/gists-code.module.css diff --git a/app/gists/gists-code.tsx b/components/pages/gists/gists-code.tsx similarity index 100% rename from app/gists/gists-code.tsx rename to components/pages/gists/gists-code.tsx diff --git a/app/gists/gists-skeleton.tsx b/components/pages/gists/gists-skeleton.tsx similarity index 100% rename from app/gists/gists-skeleton.tsx rename to components/pages/gists/gists-skeleton.tsx diff --git a/app/gists/user-info-skeleton.tsx b/components/pages/gists/user-info-skeleton.tsx similarity index 100% rename from app/gists/user-info-skeleton.tsx rename to components/pages/gists/user-info-skeleton.tsx diff --git a/app/gists/user-info.tsx b/components/pages/gists/user-info.tsx similarity index 100% rename from app/gists/user-info.tsx rename to components/pages/gists/user-info.tsx diff --git a/app/nav-bar.tsx b/components/pages/nav-bar.tsx similarity index 100% rename from app/nav-bar.tsx rename to components/pages/nav-bar.tsx diff --git a/app/projects/content.tsx b/components/pages/projects/content.tsx similarity index 100% rename from app/projects/content.tsx rename to components/pages/projects/content.tsx diff --git a/app/projects/project-card-skeleton.tsx b/components/pages/projects/project-card-skeleton.tsx similarity index 100% rename from app/projects/project-card-skeleton.tsx rename to components/pages/projects/project-card-skeleton.tsx diff --git a/app/projects/project-card.tsx b/components/pages/projects/project-card.tsx similarity index 100% rename from app/projects/project-card.tsx rename to components/pages/projects/project-card.tsx diff --git a/app/theme-provider.tsx b/components/pages/theme-provider.tsx similarity index 100% rename from app/theme-provider.tsx rename to components/pages/theme-provider.tsx