Skip to content

Commit

Permalink
Merge pull request #112 from lumirlumir/develop-refactor
Browse files Browse the repository at this point in the history
Develop refactor
  • Loading branch information
lumirlumir authored Oct 22, 2024
2 parents 974f31d + d03d4b5 commit 825cd75
Show file tree
Hide file tree
Showing 62 changed files with 260 additions and 129 deletions.
2 changes: 2 additions & 0 deletions .github/sync-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ lumirlumir/lumirlumir-configs:
- source: ./.husky/pre-commit
dest: ./configs/.husky/pre-commit
# ./.vscode
- source: ./.vscode/extensions.json
dest: ./configs/.vscode/web-extensions.json
- source: ./.vscode/settings.json
dest: ./configs/.vscode/settings.json
# ./
Expand Down
6 changes: 5 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
"summary",
"image",
"code",
"kbd"
"kbd",
"mark",
"ruby",
"rp",
"rt"
]
},
"hr-style": {
Expand Down
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"esbenp.prettier-vscode",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# blog.lumir.page

루밀LuMir의 블로그.📖
LuMir's blog. 루밀의 블로그.📖
38 changes: 14 additions & 24 deletions src/app/layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';

import ThemeProvider from '@/components/common/ThemeProvider';
import ThemeScript from '@/components/common/ThemeScript';

import Aside from '@/components/layouts/Aside';
import Body from '@/components/layouts/Body';
Expand All @@ -15,40 +16,29 @@ import Profile from '@/components/aside/Profile/Profile';
import DarkModeToggle from '@/components/header/DarkModeToggle';
import Title from '@/components/header/Title';

import { GITHUB_USER_NAME, GITHUB_USER_BIO } from '@/constants';
import { getGithubUsers } from '@/utils/fetch';

import '@/styles/global.scss';

const themeScript = `
function getTheme() {
const themeLocalStorage = localStorage.getItem('data-theme');
export async function generateMetadata() {
const { bio, name } = await getGithubUsers();

if(themeLocalStorage) return themeLocalStorage;
return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
};
document.documentElement.setAttribute('data-theme', getTheme());
`;

export const metadata = {
title: {
template: `%s | ${GITHUB_USER_NAME}`,
default: GITHUB_USER_NAME,
},
description: GITHUB_USER_BIO,
};
return {
title: {
template: `%s | ${name}`,
default: name,
},
description: bio,
};
}

export default function RootLayout({ children }) {
return (
<html lang="ko" data-theme="dark">
<ThemeProvider>
<Body>
<script
dangerouslySetInnerHTML={{
__html: themeScript,
}}
/>
<ThemeScript />

<Header>
<Title />
<DarkModeToggle />
Expand Down
9 changes: 6 additions & 3 deletions src/app/page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Article from '@/components/layouts/Article';
import { GITHUB_USER_NAME } from '@/constants';

export default function Page() {
return <Article>{`Hello, It's ${GITHUB_USER_NAME}'s blog!`}</Article>;
import { getGithubUsers } from '@/utils/fetch';

export default async function Page() {
const { name } = await getGithubUsers();

return <Article>{`Hello, It's ${name}'s blog!`}</Article>;
}
6 changes: 4 additions & 2 deletions src/components/aside/Links/Links.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Link from 'next/link';
import { FaHouseChimney, FaGithub } from 'react-icons/fa6';

import { GITHUB_USER_HTML_URL } from '@/constants';
import { getGithubUsers } from '@/utils/fetch';

import styles from './Links.module.scss';

export default async function Links() {
const { html_url } = await getGithubUsers();

return (
<ul className={styles.links}>
<li>
Expand All @@ -15,7 +17,7 @@ export default async function Links() {
</Link>
</li>
<li>
<Link href={GITHUB_USER_HTML_URL}>
<Link href={html_url}>
<FaGithub />
<span>GitHub</span>
</Link>
Expand Down
21 changes: 21 additions & 0 deletions src/components/common/ThemeScript/ThemeScript.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function ThemeScript() {
const themeScript = `
function getTheme() {
const themeLocalStorage = localStorage.getItem('data-theme');
if(themeLocalStorage) return themeLocalStorage;
return window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
};
document.documentElement.setAttribute('data-theme', getTheme());
`;

return (
<script
dangerouslySetInnerHTML={{
__html: themeScript,
}}
/>
);
}
3 changes: 3 additions & 0 deletions src/components/common/ThemeScript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ThemeScript from './ThemeScript';

export default ThemeScript;
2 changes: 1 addition & 1 deletion src/components/layouts/Aside/Aside.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.aside {
@include selector-scrollbar;
@include selector-scrollbar(2px);

position: sticky;
top: $size-header-height;
Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/Body/Body.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.body {
@include selector-scrollbar-default;
@include selector-scrollbar;

display: grid;
grid-template-rows: $size-header-height 1fr;
Expand Down
1 change: 0 additions & 1 deletion src/components/layouts/Header/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
z-index: 1;
display: grid;
grid-template-columns: $size-sidebar-width 1fr 64px;
font-size: 32px;
background-color: inherit;
border-bottom: 1px solid var(--color-border-default);

Expand Down
2 changes: 1 addition & 1 deletion src/components/layouts/Main/Main.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.main {
display: grid;
grid-template-columns: 1fr 225px;
grid-template-columns: 1fr $size-nav-width;

> article {
grid-area: 1 / 1 / 2 / 2;
Expand Down
9 changes: 2 additions & 7 deletions src/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { join } from 'path';

// GitHub User, Ref: https://docs.github.com/en/rest/users/users
export const GITHUB_USER_LOGIN = 'lumirlumir';
export const GITHUB_USER_NAME = '루밀LuMir';
export const GITHUB_USER_BIO = 'PLAY KEYBOARD, STRIKE A CODE🎨';
export const GITHUB_USER_HTML_URL = `https://github.com/${GITHUB_USER_LOGIN}`;

// GitHub Repository, Ref: https://docs.github.com/en/rest/repos/repos
export const GITHUB_REPO_OWNER = 'lumirlumir';
export const GITHUB_REPO_NAME = 'web-blog.lumir.page';
export const GITHUB_REPO_FULL_NAME = `${GITHUB_USER_LOGIN}/${GITHUB_REPO_NAME}`;
export const GITHUB_REPO_FULL_NAME = `${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}`;

// Path
export const PATH_DOCS = join(process.cwd(), 'src', 'posts', 'docs');
Expand Down
Loading

0 comments on commit 825cd75

Please sign in to comment.