Skip to content

Commit e2e27cc

Browse files
committed
fix typo
1 parent a2f9c64 commit e2e27cc

10 files changed

Lines changed: 115 additions & 14 deletions

File tree

public/book.pdf

1.82 MB
Binary file not shown.

src/app/[lang]/Home.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export default async function Home(){
2525
return (
2626
<div className="">
2727
<LanguageSwitcher />
28-
{ cards.length} bài viết.
28+
Tải sách tại <ILink href='download-book'> Link tải sách</ILink>
29+
<div>{ cards.length} bài viết.</div>
2930
{cards.map((card, index) => (
3031
<div className="card" key = {`${index}`}>
3132
<ILink href= {card.path}><h3>{card.metadata?.title}</h3>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
import style from '@/css/components/article.module.css';
4+
import path from "path";
5+
import Article from '../../components/Article';
6+
import { getAllDocPaths2 } from '../../blog/[...slug]/getAllDocPaths';
7+
8+
9+
type Params = {
10+
slug: string[]
11+
}
12+
export async function generateStaticParams(): Promise<Params[]>{
13+
const folderDir = path.join(process.cwd(), `src/content/blog`);
14+
const paths =await getAllDocPaths2(folderDir);
15+
16+
const result = paths.map(
17+
(pathArray: any ) => ({slug: pathArray}));
18+
console.log(result);
19+
if(!result || result.length===0){
20+
return [{slug: ['not-found']}];
21+
}
22+
return result
23+
}
24+
export default async function BlogPage(
25+
props: any
26+
) {
27+
28+
try{
29+
//join slug array with '/'
30+
const params = props.params;
31+
const {slug: slugArray, lang: lang} = await params;
32+
const decodeURISlugArray = slugArray.map(
33+
(segment: any)=> (decodeURIComponent(segment))
34+
)
35+
const slugPath = decodeURISlugArray.join('/')
36+
const {default: Post, metadata} = await import(`@/content/blog/${slugPath}.mdx`)
37+
if (lang==='en') {
38+
const {default: PostEn, metadata} = await import(`@/content/blogen/${slugPath}.mdx`)
39+
return (
40+
<article className={style.article}>
41+
<PostEn/>
42+
</article>
43+
)
44+
}
45+
return (<article className={style.article}>
46+
<Post/>
47+
</article>)
48+
}
49+
catch(error){
50+
console.error('Error loading this blog post')
51+
return (
52+
<div className="">
53+
<h1 className="">Error</h1>
54+
<p className="">Sorry, there was an error loading this blog post.</p>
55+
</div>
56+
)
57+
}
58+
}

src/app/[lang]/download-book/bookAction.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import puppeteer from 'puppeteer'
66
import { FormState } from '@/types/form';
77
import {PDFDocument, rgb, StandardFonts} from 'pdf-lib'
88
import { getAllMdxNodes } from '../lib/getAllMdxNodes';
9+
import Cookies from 'js-cookie';
10+
911
export default async function bookAction(
1012
prevState: FormState,
1113
formData: FormData,
@@ -59,8 +61,9 @@ export async function generatePdfBook() {
5961
const filePaths = nodes.map((node: any) => (node.dir));
6062
let urls = nodes.map((node: any) => {
6163
let path = decodeURIComponent(node.path);
62-
path = path.replace('blog', 'book')
63-
return `http://localhost:3102${path}`})
64+
path = path.replace('blog', 'book')
65+
const lang = Cookies.get('NEXT_LOCALE') || 'vi'; // fallback mặc định
66+
return `http://localhost:3102/${lang}/${path}`})
6467
// urls = ['http://localhost:3102/blog/N%E1%BB%91/']
6568
const sections = await Promise.all(
6669
urls.map((url: any) =>

src/app/[lang]/download-book/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default async function Page() {
2323
production/đọc ở web static sẽ ko hiển thị đc nút
2424
này vì nút này chuyên dùng cho back end.
2525
</p>
26-
<ILink
26+
<Link
2727
// href="/blog-book.pdf"
2828
href='/book.pdf'
2929
download
@@ -38,7 +38,7 @@ export default async function Page() {
3838
}}
3939
>
4040
📘 Download PDF Book
41-
</ILink>
41+
</Link>
4242
</div>
4343
);
4444
}

src/content/blog/1. Intro/0. Overview.mdx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
export const metadata = {
2+
title: 'Giải bài toán nhảy cầu kính',
3+
date: '2025-01-2',
4+
last_modified_at: '2025-07-16',
5+
tags: ['intro', 'draftkit']
6+
}
17

28
# Overview
3-
Draftkit là 1 cái mớ lộn xộn. Nó là 1 kho chứa các bài viết.
49

10+
Draftkit là 1 cái mớ lộn xộn. Nó là 1 kho chứa các bài viết.
511

12+
## Sơ lược về Draftkit
613

7-
Các output:
14+
### Các output:
815
- Trang web tĩnh
916
- Book pdf
1017

11-
Tính năng:
18+
### Tính năng:
1219
- Tính năng bình thường của 1 blog:
1320
+ Blog có các bài viết tạo bởi file mdx
1421
+ Có danh sách các bài viết theo thời gian
@@ -28,3 +35,26 @@ DraftKit có thể làm gì:
2835
- Lưu lại các bài viết theo cả dòng thời gian và cấu trúc
2936
thư mục.
3037
- Có thể in sách pdf từ input 1 list file mdx.
38+
39+
## Vài vấn đề về nó
40+
41+
### Tinh chỉnh trên Github pages
42+
Build web tĩnh ở Github pages có nhiều cái phải tinh chỉnh
43+
khá là trick so với build 1 trang web bình thường.
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+

src/css/components/article.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@media (min-width: 869px) {
3939
.container {
4040
display: grid;
41-
grid-template-columns: auto 300px;
41+
grid-template-columns: auto auto;
4242
}
4343
}
4444

src/css/globals.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
a,
2-
button,
3-
div, details {
2+
button, details {
43
font-family: var(--font-inter);
54
}
65

@@ -19,6 +18,12 @@ li, span {
1918
font-family: var(--font-garamond);
2019
}
2120

21+
details a, details {
22+
font-family: var(--font-garamond);
23+
font-size: 1.2rem;
24+
font-weight: 400;
25+
}
26+
2227
h1 {
2328
font-size: 2em;
2429
font-weight: bold;

src/scss/base/_typo.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
@use "../abstract/colors" as color;
22

33
a,
4-
button,
5-
div, details {
4+
button, details {
65
font-family: var(--font-inter);
76
}
87

@@ -20,6 +19,11 @@ ul,
2019
li ,span{
2120
font-family: var(--font-garamond);
2221
}
22+
details a, details{
23+
font-family: var(--font-garamond);
24+
font-size: 1.1rem;
25+
font-weight: 400;
26+
}
2327
//size and weight
2428

2529
h1 {

src/scss/components/article.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
@include display.center;
4242
@include adapts.desktop{
4343
display: grid;
44-
grid-template-columns: auto 300px;
44+
grid-template-columns: auto auto;
4545
}
4646
}
4747
.toc{

0 commit comments

Comments
 (0)