Skip to content

Commit ccc0629

Browse files
committed
feat: add dedicated book review pages (list & detail)
- closes issue #18
1 parent ad1b5d1 commit ccc0629

34 files changed

+368
-3
lines changed

components/BookCard.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Link from 'next/link';
2+
import type { BookMeta } from '../lib/books';
3+
4+
function Stars({ rating = 0 }: { rating?: number }) {
5+
const r = Math.max(0, Math.min(5, Math.round(rating)));
6+
return (
7+
<div aria-label={`rating ${r} of 5`} className="text-sm">
8+
{'★★★★★☆☆☆☆☆'.slice(5 - r, 10 - r)}
9+
</div>
10+
);
11+
}
12+
13+
export default function BookCard({ meta }: { meta: BookMeta }) {
14+
return (
15+
<article className="w-full rounded-2xl border p-6 md:p-7 mb-8 shadow-sm bg-white/60 dark:bg-zinc-900/60 backdrop-blur">
16+
<Link href={`/book/${meta.slug}`} >
17+
<div className="grid grid-cols-[96px_1fr] sm:grid-cols-[112px_1fr] lg:grid-cols-[128px_1fr] gap-6 sm:gap-8">
18+
{meta.cover && (
19+
// eslint-disable-next-line @next/next/no-img-element
20+
<img
21+
src={meta.cover}
22+
alt={meta.title}
23+
className="w-24 h-32 sm:w-28 sm:h-36 lg:w-32 lg:h-44 object-cover rounded-lg"
24+
loading="lazy"
25+
/>
26+
)}
27+
<div className="flex-1">
28+
<h2 className="text-xl font-semibold leading-snug">
29+
{meta.title}
30+
</h2>
31+
<div className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">
32+
<time dateTime={meta.updated ?? meta.date}>
33+
{meta.updated ?? meta.date}
34+
</time>
35+
</div>
36+
{meta.summary && (
37+
<p className="mt-3 leading-relaxed text-zinc-800 dark:text-zinc-200">
38+
{meta.summary}
39+
</p>
40+
)}
41+
{/* <div className="mt-2"><Stars rating={meta.rating} /></div> */}
42+
</div>
43+
</div>
44+
</Link>
45+
</article>
46+
);
47+
}

components/Header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ export default function Header({ isDark }: { isDark: boolean }) {
1515
<Link href="/post" className={`${isDark ? "text-white" : "text-black"} hover:text-blue-300 font-bold`}>
1616
Post
1717
</Link>
18+
<Link href="/book" className={`${isDark ? "text-white" : "text-black"} hover:text-blue-300 font-bold`}>
19+
Book-Review
20+
</Link>
1821
<Link href="/about" className={`${isDark ? "text-white" : "text-black"} hover:text-blue-300 font-bold`}>
1922
About
2023
</Link>
21-
<ThemeToggle />
24+
{/*<ThemeToggle />*/}
2225
</div>
2326
</header>
2427
);

posts/clean-code/9-Rules-of-Object-Oriented-Programming.mdx renamed to contents/posts/clean-code/9-Rules-of-Object-Oriented-Programming.mdx

File renamed without changes.
File renamed without changes.

posts/clean-code/local-variable-type-inference-style-guidelines.mdx renamed to contents/posts/clean-code/local-variable-type-inference-style-guidelines.mdx

File renamed without changes.

posts/clean-code/refactoring-category-summary.mdx renamed to contents/posts/clean-code/refactoring-category-summary.mdx

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)