From 5592b8683b043766dc89ec70ed07c545524a6ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Mon, 16 Sep 2024 21:43:19 +0900 Subject: [PATCH] refactor: separate UI elements into components. (#62) * refactor: create dirTree.js * refactor: detach Categories component from Aside component * refactor: detach Home component from Aside component * refactor: make Aside component as a single wrapper * rename: move src/layouts to src/components/layouts * refactor: make Article components as a single wrapper * refactor: move every grid related properties to main component * refactor: detach Title component from Header component --- src/app/docs/[...categories]/page.jsx | 3 +- src/app/layout.jsx | 37 +++++++--- src/app/page.jsx | 4 +- .../aside/Categories/Categories.jsx | 37 ++++++++++ src/components/aside/Categories/index.js | 3 + src/components/aside/Home/Home.jsx | 11 +++ src/components/aside/Home/index.js | 3 + src/components/header/Title/Title.jsx | 7 ++ src/components/header/Title/index.js | 3 + .../layouts/Article/Article.jsx | 0 .../layouts/Article/Article.module.scss | 0 src/{ => components}/layouts/Article/index.js | 0 src/components/layouts/Aside/Aside.jsx | 5 ++ .../layouts/Aside/Aside.module.scss | 1 - src/{ => components}/layouts/Aside/index.js | 0 src/{ => components}/layouts/Body/Body.jsx | 0 src/components/layouts/Body/Body.module.scss | 17 +++++ src/{ => components}/layouts/Body/index.js | 0 src/components/layouts/Header/Header.jsx | 5 ++ .../layouts/Header/Header.module.scss | 1 - src/{ => components}/layouts/Header/index.js | 0 src/components/layouts/Main/Main.jsx | 3 + src/{ => components}/layouts/Main/index.js | 0 src/layouts/Aside/Aside.jsx | 70 ------------------- src/layouts/Body/Body.module.scss | 5 -- src/layouts/Header/Header.jsx | 11 --- src/layouts/Main/Main.jsx | 5 -- src/layouts/Main/Main.module.scss | 3 - src/utils/dirTree.js | 50 +++++++++++++ 29 files changed, 175 insertions(+), 109 deletions(-) create mode 100644 src/components/aside/Categories/Categories.jsx create mode 100644 src/components/aside/Categories/index.js create mode 100644 src/components/aside/Home/Home.jsx create mode 100644 src/components/aside/Home/index.js create mode 100644 src/components/header/Title/Title.jsx create mode 100644 src/components/header/Title/index.js rename src/{ => components}/layouts/Article/Article.jsx (100%) rename src/{ => components}/layouts/Article/Article.module.scss (100%) rename src/{ => components}/layouts/Article/index.js (100%) create mode 100644 src/components/layouts/Aside/Aside.jsx rename src/{ => components}/layouts/Aside/Aside.module.scss (81%) rename src/{ => components}/layouts/Aside/index.js (100%) rename src/{ => components}/layouts/Body/Body.jsx (100%) create mode 100644 src/components/layouts/Body/Body.module.scss rename src/{ => components}/layouts/Body/index.js (100%) create mode 100644 src/components/layouts/Header/Header.jsx rename src/{ => components}/layouts/Header/Header.module.scss (82%) rename src/{ => components}/layouts/Header/index.js (100%) create mode 100644 src/components/layouts/Main/Main.jsx rename src/{ => components}/layouts/Main/index.js (100%) delete mode 100644 src/layouts/Aside/Aside.jsx delete mode 100644 src/layouts/Body/Body.module.scss delete mode 100644 src/layouts/Header/Header.jsx delete mode 100644 src/layouts/Main/Main.jsx delete mode 100644 src/layouts/Main/Main.module.scss create mode 100644 src/utils/dirTree.js diff --git a/src/app/docs/[...categories]/page.jsx b/src/app/docs/[...categories]/page.jsx index c34d317..ec03894 100644 --- a/src/app/docs/[...categories]/page.jsx +++ b/src/app/docs/[...categories]/page.jsx @@ -3,7 +3,6 @@ import parse from 'html-react-parser'; import { REPOSITORY } from '@/constants/github'; import { DOCS } from '@/constants/path'; -import Article from '@/layouts/Article'; export async function generateStaticParams() { const paths = await fs.readdir(DOCS, { @@ -24,7 +23,7 @@ export default async function Page({ params }) { 'utf-8', ); - return
{await markdownToJsx(markdown)}
; + return <>{await markdownToJsx(markdown)}; } async function markdownToHtml(markdown) { diff --git a/src/app/layout.jsx b/src/app/layout.jsx index 11dbdd1..d4ff0e2 100644 --- a/src/app/layout.jsx +++ b/src/app/layout.jsx @@ -1,17 +1,38 @@ import { SpeedInsights } from '@vercel/speed-insights/next'; -import Aside from '@/layouts/Aside'; -import Body from '@/layouts/Body'; -import Header from '@/layouts/Header'; -import Main from '@/layouts/Main'; +import Article from '@/components/layouts/Article'; +import Aside from '@/components/layouts/Aside'; +import Body from '@/components/layouts/Body'; +import Header from '@/components/layouts/Header'; +import Main from '@/components/layouts/Main'; -export default function Layout({ children }) { +import Categories from '@/components/aside/Categories'; +import Home from '@/components/aside/Home'; + +import Title from '@/components/header/Title'; + +// TODO: import '@/styles/global.scss'; + +// TODO: export const metadata = { +// title: 'Next.js', +// description: 'Generated by Next.js', +// }; + +export default function RootLayout({ children }) { return ( -
-