-
Notifications
You must be signed in to change notification settings - Fork 0
blog: add header #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blog: add header #44
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||
| Hi, I'm Gapry. Nice to meet you! I love drinking coffee. | ||||||
|
|
||||||
|  | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The image is missing alternative text (alt text). Alt text is crucial for accessibility, as it provides a description of the image for screen readers and is displayed if the image fails to load. Please add a descriptive alt text.
Suggested change
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; | |
| import Analytics from './components/Analytics'; | ||
| import NotFound from './pages/NotFound/NotFound'; | ||
| import Home from './pages/Home/Home'; | ||
| import Header from './components/Header/Header'; | ||
| import Footer from './components/Footer/Footer'; | ||
| import './styles/App.css'; | ||
|
|
||
|
|
@@ -32,6 +33,17 @@ export default function App() { | |
| const pathClean = currentPath.replace(/\.html$/, ''); | ||
| const parts = pathClean.split('/').filter(Boolean); | ||
|
|
||
| if (parts.length === 1 && parts[0] === 'about') { | ||
| fetch('/about.md') | ||
| .then(res => res.text()) | ||
| .then(text => { | ||
| setContent(text); | ||
| setStatus('post'); | ||
| }) | ||
| .catch(() => setStatus('404')); | ||
| return; | ||
| } | ||
|
Comment on lines
+36
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The routing logic for the |
||
|
|
||
| if (parts.length === 0 || (parts.length === 1 && parts[0] === 'index')) { | ||
| setStatus('home'); | ||
| return; | ||
|
|
@@ -73,6 +85,7 @@ export default function App() { | |
| <> | ||
| <Analytics /> | ||
| <div className="app-shell"> | ||
| <Header /> | ||
| {status === '404' ? ( | ||
| <NotFound /> | ||
| ) : status === 'home' ? ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| .site-header { | ||
| width: 100%; | ||
| border-bottom: 1px solid #333; | ||
| padding: 1.5rem 0; | ||
| margin-bottom: 2rem; | ||
| } | ||
|
|
||
| .header-container { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: flex-end; | ||
| max-width: 800px; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .logo { | ||
| font-size: 2.0rem; | ||
| font-weight: bold; | ||
| text-decoration: none; | ||
| color: #fff; | ||
| line-height: 1; | ||
| } | ||
|
|
||
| .nav-menu { | ||
| list-style: none; | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 20px; | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
|
|
||
| .nav-menu a { | ||
| display: flex; | ||
| align-items: center; | ||
| text-decoration: none; | ||
| color: #aaa; | ||
| transition: color 0.2s; | ||
| line-height: 1; | ||
| } | ||
|
|
||
| .nav-menu a:hover { | ||
| color: #646cff; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import siteConfig from '../../data/config.json'; | ||
| import './Header.css'; | ||
|
|
||
| export default function Header() { | ||
| return ( | ||
| <header className="site-header"> | ||
| <div className="header-container"> | ||
| <div className="header-left"> | ||
| <a href="/" className="logo"> | ||
| {siteConfig.siteName} | ||
| </a> | ||
| </div> | ||
|
|
||
| <nav className="header-right"> | ||
| <ul className="nav-menu"> | ||
| <li><a href="/about">About Me</a></li> | ||
| </ul> | ||
| </nav> | ||
|
Comment on lines
+8
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The links in the header (
|
||
| </div> | ||
| </header> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| } | ||
|
|
||
| .home-title { | ||
| font-size: 2rem; | ||
| font-size: 1.5rem; | ||
| margin-bottom: 30px; | ||
| color: #ffffff; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds another
fs.copyFileSynccall to copyindex.html. There is now duplicated logic for copyingindex.htmlto404.htmlandabout.html. Consider refactoring this to use a loop to improve maintainability and avoid repetition, for example: