From 74174bda99f1784030bfaa18f460e4efe255f1f6 Mon Sep 17 00:00:00 2001 From: ethan 3 Date: Mon, 24 Feb 2025 07:49:28 +0000 Subject: [PATCH 1/7] library flow --- pages/_app.tsx | 3 +++ pages/library.mdx | 35 +++++++++++++++++++++++++++++++++++ translation/en-US.ts | 3 +++ translation/zh-CN.ts | 3 +++ translation/zh-TW.ts | 3 +++ 5 files changed, 47 insertions(+) create mode 100644 pages/library.mdx diff --git a/pages/_app.tsx b/pages/_app.tsx index b2e8102..b894528 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -45,6 +45,9 @@ const App: FC = observer(({ Component, pageProps }) => { href: 'https://github.com/Open-Source-Bazaar/Git-Hackathon-scaffold', name: t('hackathon'), }, + { + href: '/library', name: t('open_library'), + }, ]; return ( <> diff --git a/pages/library.mdx b/pages/library.mdx new file mode 100644 index 0000000..57c90da --- /dev/null +++ b/pages/library.mdx @@ -0,0 +1,35 @@ +# 社区图书馆 + +## 简介 + +freeCodeCamp 成都社区「Open Library」是一个开放、共享的社区图书馆,旨在促进知识交流,推动社区成员之间的学习和成长,增强社区成员之间的互动与信任。我们深知知识的流动能够点燃创新的火花,因此,我们采用了一种独特的“无储存”借阅模式,让书籍在会员之间自由流转,而非集中存放。 + +## 申请会员 + +如果你热爱阅读,愿意分享知识,欢迎填写 fCC 成都社区图书馆-会员申请,加入 freeCodeCamp 成都社区「Open Library」,成为知识流动的一部分! + +## 书籍募捐 + +我们鼓励社区成员捐赠书籍,共同丰富书目资源。捐赠流程如下: + +1. **填写捐赠申请**:填写 fCC 成都社区图书馆-书籍捐赠。 + +2. **书籍登记**:如所捐赠书籍在「 fCC 成都社区图书馆」还未登记,请先填写 fCC 成都社区图书馆-书籍登记,然后回到第 1 步继续捐赠。建议在移动端设备上登记,方便扫描书籍 ISBN 码。 + +3. **书籍进入图书馆**:完成以上流程后,书籍正式进入 Open Library 的传递流程,开始流转于社区成员之间。 + +## 借阅与传递 + +在 Open Library,所有书籍均来自社区成员的捐赠,并由借阅者直接**传递**给下一位借书人。 + +借阅流程如下: + +1. **查阅书籍**:社区成员可以在 fCC 成都社区图书馆中查找自己感兴趣的书籍。 +2. **申请借阅**:填写 fCC 成都社区图书馆-书籍借入申请,与当前持书者取得联系。 +3. **线下传递**:双方约定时间和传递方式,通常可用快递传递书籍。请传递者填写 fCC 成都社区图书馆-书籍传递,再将书籍传递出去。 +4. **阅读与分享**:借阅者在阅读完毕后,可以分享自己的阅读感悟,并在社区推荐给下一位感兴趣的成员。 +5. **继续传递**:当有新的借阅者申请时,当前持书人将书籍传递给下一位读者,确保知识的持续流动。 + +## 未来 + +期待未来可以与更多开放空间合作,定期举办主题阅读会。 \ No newline at end of file diff --git a/translation/en-US.ts b/translation/en-US.ts index abbb596..7e0ac36 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -11,4 +11,7 @@ export default { // Search keywords: 'Keywords', search_results: 'Search Results', + + // Open Library + open_library: "Open Library", }; diff --git a/translation/zh-CN.ts b/translation/zh-CN.ts index 7baf329..44edfe7 100644 --- a/translation/zh-CN.ts +++ b/translation/zh-CN.ts @@ -11,4 +11,7 @@ export default { // Search keywords: '关键词', search_results: '搜索结果', + + // Open Library + open_library: "开源图书馆", }; diff --git a/translation/zh-TW.ts b/translation/zh-TW.ts index 024e7fb..be691cc 100644 --- a/translation/zh-TW.ts +++ b/translation/zh-TW.ts @@ -11,4 +11,7 @@ export default { // Search keywords: '關鍵詞', search_results: '搜尋結果', + + // Open Library + open_library: "開源圖書館", }; From 07745ad86bc52e9c5ce68a5b83fd84eeacf70fb1 Mon Sep 17 00:00:00 2001 From: dethan3 Date: Fri, 18 Apr 2025 16:16:34 +0800 Subject: [PATCH 2/7] [feat] Initial open-library homepage, component & hook fix --- .husky/pre-commit | 2 +- components/open-library/Footer.tsx | 69 ++++ components/open-library/Navbar.tsx | 46 +++ package.json | 3 +- pages/_app.tsx | 3 +- pages/open-library/index.tsx | 345 ++++++++++++++++++ pages/{library.mdx => open-library/readme.md} | 2 +- 7 files changed, 466 insertions(+), 4 deletions(-) create mode 100644 components/open-library/Footer.tsx create mode 100644 components/open-library/Navbar.tsx create mode 100644 pages/open-library/index.tsx rename pages/{library.mdx => open-library/readme.md} (99%) diff --git a/.husky/pre-commit b/.husky/pre-commit index 255814b..98475b5 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1 @@ -npm test +pnpm test diff --git a/components/open-library/Footer.tsx b/components/open-library/Footer.tsx new file mode 100644 index 0000000..124e088 --- /dev/null +++ b/components/open-library/Footer.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { Container, Row, Col, Nav } from 'react-bootstrap'; + +const FooterComponent = () => { + return ( +
+ + + +
Open Library
+

+ A community-driven library for sharing knowledge and stories. + Built with open source. Powered by generosity. +

+ + +
Quick Links
+ + + +
Contact
+

Email: info@openlibrary.community

+

Address: 123 Library Lane, Knowledge City, World

+ + +
Follow Us
+ + +
+ + + + © {new Date().getFullYear()} Open Library Community. All + Rights Reserved. + + + +
+
+ ); +}; + +export default FooterComponent; diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx new file mode 100644 index 0000000..28767c5 --- /dev/null +++ b/components/open-library/Navbar.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import { + Navbar, + Nav, + Container, + Button, + Form, + FormControl, +} from 'react-bootstrap'; + +const NavbarComponent = () => { + return ( + + + + Open Library + + + + +
+ + + + +
+
+
+ ); +}; + +export default NavbarComponent; diff --git a/package.json b/package.json index 2e2cd5e..d3c513d 100644 --- a/package.json +++ b/package.json @@ -81,5 +81,6 @@ }, "lint-staged": { "*.{html,md,scss,json,yml,js,mjs,ts,tsx}": "prettier --write" - } + }, + "packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677" } diff --git a/pages/_app.tsx b/pages/_app.tsx index b894528..6818a20 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -46,7 +46,8 @@ const App: FC = observer(({ Component, pageProps }) => { name: t('hackathon'), }, { - href: '/library', name: t('open_library'), + href: '/open-library', + name: t('open_library'), }, ]; return ( diff --git a/pages/open-library/index.tsx b/pages/open-library/index.tsx new file mode 100644 index 0000000..ef893f5 --- /dev/null +++ b/pages/open-library/index.tsx @@ -0,0 +1,345 @@ +import React from 'react'; +import Link from 'next/link'; +import { + Container, + Row, + Col, + Button, + Card, + Form, + Image, + Stack, +} from 'react-bootstrap'; +import NavbarComponent from '../../components/open-library/Navbar'; +import FooterComponent from '../../components/open-library/Footer'; + +// TODO: Define a type for Book and Testimonial +type Book = { + id: number; + title: string; + author: string; + cover?: string; // Optional cover image URL +}; + +type Testimonial = { + id: number; + name: string; + quote: string; +}; + +export default function OpenLibraryHomepage() { + // Sample featured books data + const featuredBooks: Book[] = [ + { + id: 1, + title: 'Clean Code', + author: 'Robert C. Martin', + cover: '/images/placeholder-book.svg', + }, // TODO: Replace placeholder path + { + id: 2, + title: 'Eloquent JavaScript', + author: 'Marijn Haverbeke', + cover: '/images/placeholder-book.svg', + }, + { + id: 3, + title: 'Design Patterns', + author: 'Erich Gamma et al.', + cover: '/images/placeholder-book.svg', + }, + { + id: 4, + title: "You Don't Know JS", + author: 'Kyle Simpson', + cover: '/images/placeholder-book.svg', + }, + ]; + + // Sample testimonials data + const testimonials: Testimonial[] = [ + { + id: 1, + name: 'Zhang Wei', + quote: + "Open Library helped me discover amazing tech books I couldn't find elsewhere.", + }, + { + id: 2, + name: 'Li Mei', + quote: + "The community is so supportive. I've both borrowed and donated books here.", + }, + { + id: 3, + name: 'Wang Chen', + quote: + 'As a student, this resource has been invaluable for my studies in computer science.', + }, + ]; + + return ( + <> + {/* --- Navbar --- */} + + +
+ {/* --- Hero Section --- */} +
+ + + +

+ Free knowledge flows here +

+

+ Share and borrow books in our open-source community. Join + freeCodeCamp Chengdu's initiative to make learning accessible + to everyone. +

+ {/* TODO: Link this button to the actual Feishu form or member sign-up page */} + + + + {/* TODO: Replace placeholder */} + People sharing books + +
+
+
+ + {/* --- Featured Books Section --- */} +
+ +

Featured Books

+

+ Discover what our community is reading right now +

+ + {featuredBooks.map(book => ( + // TODO: Potentially move Card rendering to components/open-library/BookCard.tsx + + +
+ {`${book.title} +
+ + + {book.title} + + + {book.author} + +
+ + + +
+
+
+ + ))} +
+
+ + + +
+
+
+ + {/* --- Donation Callout Section --- */} +
+ + + +

Share Your Knowledge

+

+ Have books collecting dust on your shelf? Donate them to our + community and help others learn and grow. Your contribution + makes a difference! +

+ + + + + + {/* TODO: Replace placeholder */} + Book donation + +
+
+
+ + {/* --- How It Works Section --- */} +
+ +

How It Works

+

+ Three simple steps to borrow books from our community +

+ + +
+ +
+

1. Find a Book

+

+ Browse our collection and find the book that interests you. + Filter by category, author, or popularity. +

+ + +
+ +
+

2. Apply to Borrow

+

+ Submit a simple request form. We'll connect you with the book + owner and arrange the handover. +

+ + +
+ +
+

3. Receive and Pass It On

+

+ Enjoy your book and return it when you're done. Consider + donating your own books to keep knowledge flowing. +

+ +
+
+ + + +
+
+
+ + {/* --- Testimonials Section --- */} +
+ +

Community Voices

+

+ What our members say about Open Library +

+ + {testimonials.map(testimonial => ( + + + +
+

"{testimonial.quote}"

+
+ {testimonial.name} +
+
+
+
+ + ))} +
+
+ + + +
+
+
+ + {/* --- Newsletter Section --- */} +
+ + + + + +

Stay Updated

+

+ Subscribe to our newsletter for new book arrivals and + community events. +

+ {/* TODO: Implement actual newsletter subscription logic */} +
e.preventDefault()}> + {' '} + {/* Prevent default form submission */} + + + + +
+
+
+ +
+
+
+
+ + {/* --- Footer --- */} + + + ); +} diff --git a/pages/library.mdx b/pages/open-library/readme.md similarity index 99% rename from pages/library.mdx rename to pages/open-library/readme.md index 57c90da..b9d7c47 100644 --- a/pages/library.mdx +++ b/pages/open-library/readme.md @@ -32,4 +32,4 @@ freeCodeCamp 成都社区「Open Library」是一个开放、共享的社区图 ## 未来 -期待未来可以与更多开放空间合作,定期举办主题阅读会。 \ No newline at end of file +期待未来可以与更多开放空间合作,定期举办主题阅读会。 From e10b0b1f5259722d1416132eefa73b4d6b683c6e Mon Sep 17 00:00:00 2001 From: dethan3 Date: Thu, 24 Apr 2025 12:57:24 +0800 Subject: [PATCH 3/7] feat: customize Open Library layout and styling --- components/open-library/Footer.tsx | 25 +++- components/open-library/Layout.tsx | 60 +++++++++ components/open-library/Navbar.tsx | 36 +++-- pages/_app.tsx | 126 +++++++++-------- pages/open-library/index.tsx | 208 ++++++++++++++++++++++++----- 5 files changed, 352 insertions(+), 103 deletions(-) create mode 100644 components/open-library/Layout.tsx diff --git a/components/open-library/Footer.tsx b/components/open-library/Footer.tsx index 124e088..cde0a5f 100644 --- a/components/open-library/Footer.tsx +++ b/components/open-library/Footer.tsx @@ -1,10 +1,29 @@ import React from 'react'; -import { Container, Row, Col, Nav } from 'react-bootstrap'; +import { Row, Col, Nav } from 'react-bootstrap'; + +// +const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => { + return ( +
+ {children} +
+ ); +}; const FooterComponent = () => { return (
- +
Open Library
@@ -61,7 +80,7 @@ const FooterComponent = () => {
-
+
); }; diff --git a/components/open-library/Layout.tsx b/components/open-library/Layout.tsx new file mode 100644 index 0000000..bace01f --- /dev/null +++ b/components/open-library/Layout.tsx @@ -0,0 +1,60 @@ +import React from 'react'; +import Head from 'next/head'; +import NavbarComponent from './Navbar'; +import FooterComponent from './Footer'; + +// 内容容器组件,使内容居中但不添加边框 +const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => { + return ( +
+ {children} +
+ ); +}; + +interface LayoutProps { + children: React.ReactNode; + title?: string; +} + +/** + * Open Library 的共享布局组件 + * 包含导航栏、页脚和内容容器 + * 所有 Open Library 页面都应使用此布局 + */ +const Layout: React.FC = ({ + children, + title = 'Open Library - Open Source Bazaar', +}) => { + return ( + <> + + {title} + + + + {/* 导航栏 */} + + + {/* 主要内容 */} +
{children}
+ + {/* 页脚 */} + + + ); +}; + +// 导出布局组件和内容容器组件,以便在页面中使用 +export { Layout, ContentContainer }; +export default Layout; diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx index 28767c5..8e40419 100644 --- a/components/open-library/Navbar.tsx +++ b/components/open-library/Navbar.tsx @@ -11,19 +11,37 @@ import { const NavbarComponent = () => { return ( - - + {/* 使用自定义的居中容器替代 Container fluid,与页面内容保持一致的宽度和居中效果 */} +
+ Open Library
{ Login/Register - +
); }; diff --git a/pages/_app.tsx b/pages/_app.tsx index 6818a20..99c7009 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -35,6 +35,9 @@ const App: FC = observer(({ Component, pageProps }) => { const { pathname } = useRouter(); const thisFullYear = new Date().getFullYear(); + // 检查是否是 Open Library 路径 + const isOpenLibraryPath = pathname.startsWith('/open-library'); + const topNavBarMenu = [ { href: '/about', name: t('about') }, { href: '/history', name: t('history') }, @@ -59,62 +62,75 @@ const App: FC = observer(({ Component, pageProps }) => { - - - - {t('open_source_bazaar')} - - - - - - - - - - -
- - - -
- - + )} ); }); diff --git a/pages/open-library/index.tsx b/pages/open-library/index.tsx index ef893f5..91d6bfa 100644 --- a/pages/open-library/index.tsx +++ b/pages/open-library/index.tsx @@ -1,17 +1,7 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import Link from 'next/link'; -import { - Container, - Row, - Col, - Button, - Card, - Form, - Image, - Stack, -} from 'react-bootstrap'; -import NavbarComponent from '../../components/open-library/Navbar'; -import FooterComponent from '../../components/open-library/Footer'; +import { Row, Col, Button, Card, Form, Image, Stack } from 'react-bootstrap'; +import { Layout, ContentContainer } from '../../components/open-library/Layout'; // TODO: Define a type for Book and Testimonial type Book = { @@ -78,11 +68,160 @@ export default function OpenLibraryHomepage() { }, ]; - return ( - <> - {/* --- Navbar --- */} - + // Use client-side code to hide the main site header and adjust layout + useEffect(() => { + // Function to apply style to an element + const applyStyle = ( + element: HTMLElement | null, + styles: Partial, + ) => { + if (!element) return; + + Object.entries(styles).forEach(([property, value]) => { + if (value) { + // @ts-ignore: dynamic property assignment + element.style[property] = value; + } + }); + }; + + // Hide the main site header + const mainHeader = document.querySelector( + 'nav.navbar.bg-dark.navbar-dark.fixed-top', + ); + applyStyle(mainHeader as HTMLElement, { display: 'none' }); + + // Remove top margin that accommodates the main header + const mainContent = document.querySelector('div.mt-5.pt-2'); + applyStyle(mainContent as HTMLElement, { + marginTop: '0', + paddingTop: '0', + maxWidth: '100%', + width: '100%', + }); + + // Remove background and padding from main content + const mainWrapper = document.querySelector( + 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', + ); + applyStyle(mainWrapper as HTMLElement, { + background: 'none', + padding: '0', + margin: '0', + maxWidth: '100%', + width: '100%', + }); + + // Remove container constraints + const containers = document.querySelectorAll('.container'); + containers.forEach(container => { + applyStyle(container as HTMLElement, { + maxWidth: '100%', + padding: '0', + margin: '0', + }); + }); + + // Remove card styling + const cards = document.querySelectorAll('.card'); + cards.forEach(card => { + if ( + card.closest( + 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', + ) + ) { + applyStyle(card as HTMLElement, { + background: 'transparent', + border: 'none', + boxShadow: 'none', + padding: '0', + margin: '0', + }); + } + }); + + // Remove card body padding + const cardBodies = document.querySelectorAll('.card-body'); + cardBodies.forEach(cardBody => { + if ( + cardBody.closest( + 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', + ) + ) { + applyStyle(cardBody as HTMLElement, { + padding: '0', + }); + } + }); + // Hide the main site footer + const mainFooter = document.querySelector( + 'footer.mw-100.bg-dark.text-white', + ); + applyStyle(mainFooter as HTMLElement, { display: 'none' }); + + // Remove all padding and margin from body and html + applyStyle(document.body, { + margin: '0', + padding: '0', + overflow: 'auto', + }); + + applyStyle(document.documentElement, { + margin: '0', + padding: '0', + overflow: 'auto', + }); + + // Target the MDXProvider wrapper (main white background) + const mdxProvider = document.querySelector(`.MDXProvider`); + applyStyle(mdxProvider as HTMLElement, { + padding: '0 !important', + margin: '0 !important', + background: 'transparent !important', + border: 'none !important', + boxShadow: 'none !important', + }); + + // Add custom styles to ensure full width + const style = document.createElement('style'); + style.textContent = ` + body, html { + margin: 0 !important; + padding: 0 !important; + overflow-x: hidden !important; + } + .container, .container-fluid { + max-width: 100% !important; + padding-left: 0 !important; + padding-right: 0 !important; + margin-left: 0 !important; + margin-right: 0 !important; + } + main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center { + padding: 0 !important; + margin: 0 !important; + max-width: 100% !important; + width: 100% !important; + } + main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center > .container { + max-width: 100% !important; + padding: 0 !important; + margin: 0 !important; + } + .MDXProvider { + padding: 0 !important; + margin: 0 !important; + background: transparent !important; + border: none !important; + box-shadow: none !important; + } + `; + document.head.appendChild(style); + }, []); + + return ( +
{/* --- Hero Section --- */}
- +

@@ -119,12 +258,12 @@ export default function OpenLibraryHomepage() { /> - +

{/* --- Featured Books Section --- */}
- +

Featured Books

Discover what our community is reading right now @@ -174,16 +313,16 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Browse All Books → + Browse All Books - +

{/* --- Donation Callout Section --- */}
- +

Share Your Knowledge

@@ -207,12 +346,12 @@ export default function OpenLibraryHomepage() { />
-
+
{/* --- How It Works Section --- */}
- +

How It Works

Three simple steps to borrow books from our community @@ -255,16 +394,16 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Learn More About Borrowing → + Learn More About Borrowing - +

{/* --- Testimonials Section --- */}
- +

Community Voices

What our members say about Open Library @@ -291,16 +430,16 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Read More Reviews → + Read More Reviews - +

{/* --- Newsletter Section --- */}
- + @@ -334,12 +473,9 @@ export default function OpenLibraryHomepage() { - +
- - {/* --- Footer --- */} - - +
); } From 69dbf8b67af1c783a8ff0cc1bdb724648dca1d3e Mon Sep 17 00:00:00 2001 From: dethan3 Date: Thu, 24 Apr 2025 13:38:45 +0800 Subject: [PATCH 4/7] fix: resolve import sorting and TS annotation issues --- components/open-library/Footer.tsx | 2 +- components/open-library/Layout.tsx | 7 ++++--- components/open-library/Navbar.tsx | 9 +-------- pages/open-library/index.tsx | 9 +++++---- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/components/open-library/Footer.tsx b/components/open-library/Footer.tsx index cde0a5f..d9acd09 100644 --- a/components/open-library/Footer.tsx +++ b/components/open-library/Footer.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Row, Col, Nav } from 'react-bootstrap'; +import { Col, Nav, Row } from 'react-bootstrap'; // const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ diff --git a/components/open-library/Layout.tsx b/components/open-library/Layout.tsx index bace01f..2f4def9 100644 --- a/components/open-library/Layout.tsx +++ b/components/open-library/Layout.tsx @@ -1,7 +1,8 @@ -import React from 'react'; import Head from 'next/head'; -import NavbarComponent from './Navbar'; +import React from 'react'; + import FooterComponent from './Footer'; +import NavbarComponent from './Navbar'; // 内容容器组件,使内容居中但不添加边框 const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ @@ -56,5 +57,5 @@ const Layout: React.FC = ({ }; // 导出布局组件和内容容器组件,以便在页面中使用 -export { Layout, ContentContainer }; export default Layout; +export { ContentContainer, Layout }; diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx index 8e40419..a71ac23 100644 --- a/components/open-library/Navbar.tsx +++ b/components/open-library/Navbar.tsx @@ -1,12 +1,5 @@ import React from 'react'; -import { - Navbar, - Nav, - Container, - Button, - Form, - FormControl, -} from 'react-bootstrap'; +import { Button, Form, FormControl, Nav, Navbar } from 'react-bootstrap'; const NavbarComponent = () => { return ( diff --git a/pages/open-library/index.tsx b/pages/open-library/index.tsx index 91d6bfa..074b5e7 100644 --- a/pages/open-library/index.tsx +++ b/pages/open-library/index.tsx @@ -1,7 +1,8 @@ -import React, { useEffect } from 'react'; import Link from 'next/link'; -import { Row, Col, Button, Card, Form, Image, Stack } from 'react-bootstrap'; -import { Layout, ContentContainer } from '../../components/open-library/Layout'; +import React, { useEffect } from 'react'; +import { Button, Card, Col, Form, Image, Row, Stack } from 'react-bootstrap'; + +import { ContentContainer, Layout } from '../../components/open-library/Layout'; // TODO: Define a type for Book and Testimonial type Book = { @@ -79,7 +80,7 @@ export default function OpenLibraryHomepage() { Object.entries(styles).forEach(([property, value]) => { if (value) { - // @ts-ignore: dynamic property assignment + // @ts-expect-error: dynamic property assignment element.style[property] = value; } }); From a72c2eee8578d4200caaae0bc51e79d08120dba8 Mon Sep 17 00:00:00 2001 From: dethan3 Date: Fri, 25 Apr 2025 14:18:41 +0800 Subject: [PATCH 5/7] feat: implement Open Library basic framework with multilingual support --- .husky/pre-push | 2 +- components/open-library/Footer.tsx | 120 +++-- components/open-library/Layout.tsx | 13 +- components/open-library/Navbar.tsx | 48 +- .../open-library/useOpenLibraryLayout.ts | 20 + pages/_app.tsx | 1 + pages/api/hello.ts | 10 +- pages/open-library/about.tsx | 201 ++++++++ pages/open-library/book/[id].tsx | 453 ++++++++++++++++++ pages/open-library/books/index.tsx | 318 ++++++++++++ pages/open-library/donate.tsx | 254 ++++++++++ pages/open-library/how-to-borrow.tsx | 294 ++++++++++++ pages/open-library/index.tsx | 241 ++-------- pages/open-library/review.tsx | 372 ++++++++++++++ styles/open-library.css | 65 +++ translation/en-US.ts | 149 +++++- translation/zh-CN.ts | 146 +++++- translation/zh-TW.ts | 145 +++++- 18 files changed, 2570 insertions(+), 282 deletions(-) create mode 100644 components/open-library/useOpenLibraryLayout.ts create mode 100644 pages/open-library/about.tsx create mode 100644 pages/open-library/book/[id].tsx create mode 100644 pages/open-library/books/index.tsx create mode 100644 pages/open-library/donate.tsx create mode 100644 pages/open-library/how-to-borrow.tsx create mode 100644 pages/open-library/review.tsx create mode 100644 styles/open-library.css diff --git a/.husky/pre-push b/.husky/pre-push index da7be55..0c958d2 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1 @@ -npm run build +pnpm run build diff --git a/components/open-library/Footer.tsx b/components/open-library/Footer.tsx index d9acd09..c17b219 100644 --- a/components/open-library/Footer.tsx +++ b/components/open-library/Footer.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { Col, Nav, Row } from 'react-bootstrap'; +import { t } from '../../models/Translation'; + // const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ children, @@ -21,65 +23,95 @@ const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ }; const FooterComponent = () => { + // Use client-side rendering for the copyright text to avoid hydration issues + const [isMounted, setIsMounted] = React.useState(false); + + React.useEffect(() => { + setIsMounted(true); + }, []); + return (
-
Open Library
-

- A community-driven library for sharing knowledge and stories. - Built with open source. Powered by generosity. -

- - -
Quick Links
- - - -
Contact
-

Email: info@openlibrary.community

-

Address: 123 Library Lane, Knowledge City, World

- - -
Follow Us
-
- - Facebook +
{t('open_library')}
+

{t('footer_description')}

+
- - - - - © {new Date().getFullYear()} Open Library Community. All - Rights Reserved. - + +
{t('quick_links_footer')}
+ + + +
{t('contact')}
+

freeCodeCamp Chengdu Community

+

Chengdu, Sichuan, China

+

Email: contact@openlibrary.org

+

WeChat: FCCChengdu

+ +
+ + {/* Use a more direct approach with inline styles to ensure visibility */} +
+ {isMounted ? ( + <> + © {new Date().getFullYear()} {t('open_library')}.{' '} + {t('all_rights_reserved')} + + ) : ( + <> + © {new Date().getFullYear()} Open Library. All rights + reserved. + + )} +
); diff --git a/components/open-library/Layout.tsx b/components/open-library/Layout.tsx index 2f4def9..92e09d5 100644 --- a/components/open-library/Layout.tsx +++ b/components/open-library/Layout.tsx @@ -2,9 +2,9 @@ import Head from 'next/head'; import React from 'react'; import FooterComponent from './Footer'; -import NavbarComponent from './Navbar'; +import LibraryNavbar from './Navbar'; +import { useOpenLibraryLayout } from './useOpenLibraryLayout'; -// 内容容器组件,使内容居中但不添加边框 const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ children, }) => { @@ -37,6 +37,9 @@ const Layout: React.FC = ({ children, title = 'Open Library - Open Source Bazaar', }) => { + // Apply Open Library layout styles + useOpenLibraryLayout(); + return ( <> @@ -44,18 +47,14 @@ const Layout: React.FC = ({ - {/* 导航栏 */} - + - {/* 主要内容 */}
{children}
- {/* 页脚 */} ); }; -// 导出布局组件和内容容器组件,以便在页面中使用 export default Layout; export { ContentContainer, Layout }; diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx index a71ac23..1b2fd35 100644 --- a/components/open-library/Navbar.tsx +++ b/components/open-library/Navbar.tsx @@ -1,7 +1,22 @@ +import dynamic from 'next/dynamic'; import React from 'react'; import { Button, Form, FormControl, Nav, Navbar } from 'react-bootstrap'; -const NavbarComponent = () => { +import { t } from '../../models/Translation'; + +// 动态导入 LanguageMenu 组件,禁用 SSR +const LanguageMenu = dynamic(() => import('../Navigator/LanguageMenu'), { + ssr: false, +}); + +const LibraryNavbar = () => { + // Use a client-side only rendering approach for the brand text to avoid hydration mismatch + const [isMounted, setIsMounted] = React.useState(false); + + React.useEffect(() => { + setIsMounted(true); + }, []); + return ( {/* 使用自定义的居中容器替代 Container fluid,与页面内容保持一致的宽度和居中效果 */} @@ -22,36 +37,27 @@ const NavbarComponent = () => { href="/open-library" className="d-flex align-items-center" > - Open Library + {/* Use a static placeholder during SSR and replace it with translated content after hydration */} + {isMounted ? t('open_library') : 'Open Library'} - - - - - + {/* 添加语言切换菜单 */} + ); }; -export default NavbarComponent; +export default LibraryNavbar; diff --git a/components/open-library/useOpenLibraryLayout.ts b/components/open-library/useOpenLibraryLayout.ts new file mode 100644 index 0000000..cd15c3d --- /dev/null +++ b/components/open-library/useOpenLibraryLayout.ts @@ -0,0 +1,20 @@ +import { useEffect } from 'react'; + +/** + * Hook to apply Open Library layout styles + * This adds the open-library class to the body and html elements + * which triggers the CSS rules in styles/open-library.css + */ +export function useOpenLibraryLayout() { + useEffect(() => { + // Add open-library class to body and html + document.body.classList.add('open-library'); + document.documentElement.classList.add('open-library'); + + // Clean up function to remove classes when component unmounts + return () => { + document.body.classList.remove('open-library'); + document.documentElement.classList.remove('open-library'); + }; + }, []); +} diff --git a/pages/_app.tsx b/pages/_app.tsx index 99c7009..12b87f9 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,4 +1,5 @@ import '../styles/globals.css'; +import '../styles/open-library.css'; import { HTTPError } from 'koajax'; import { configure } from 'mobx'; diff --git a/pages/api/hello.ts b/pages/api/hello.ts index f8bcc7e..46714b3 100644 --- a/pages/api/hello.ts +++ b/pages/api/hello.ts @@ -1,13 +1,13 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction -import type { NextApiRequest, NextApiResponse } from 'next' +import type { NextApiRequest, NextApiResponse } from 'next'; type Data = { - name: string -} + name: string; +}; export default function handler( req: NextApiRequest, - res: NextApiResponse + res: NextApiResponse, ) { - res.status(200).json({ name: 'John Doe' }) + res.status(200).json({ name: 'John Doe' }); } diff --git a/pages/open-library/about.tsx b/pages/open-library/about.tsx new file mode 100644 index 0000000..c8a8bf1 --- /dev/null +++ b/pages/open-library/about.tsx @@ -0,0 +1,201 @@ +import React from 'react'; +import { Card, Col, Container, Image, Row } from 'react-bootstrap'; + +import { ContentContainer, Layout } from '../../components/open-library/Layout'; + +export default function AboutPage() { + return ( + + +
+

关于社区图书馆

+ + + +

我们的使命

+

+ freeCodeCamp 成都社区「Open + Library」是一个开放、共享的社区图书馆,旨在促进知识交流,推动社区成员之间的学习和成长,增强社区成员之间的互动与信任。 +

+

+ 我们深知知识的流动能够点燃创新的火花,因此,我们采用了一种独特的"无储存"借阅模式,让书籍在会员之间自由流转,而非集中存放。这种模式不仅节省了物理空间,更重要的是促进了社区成员之间的直接交流和互动。 +

+
+
+ + + + + +

我们的价值观

+
    +
  • +
    +
    + +
    +
    +
    开放共享
    +

    + 我们相信知识应该是开放和共享的,每个人都有权利获取和贡献知识。 +

    +
    +
    +
  • +
  • +
    +
    + +
    +
    +
    社区驱动
    +

    + 我们的图书馆完全由社区成员驱动,每个人都可以贡献和受益。 +

    +
    +
    +
  • +
  • +
    +
    + +
    +
    +
    信任与责任
    +

    + 我们基于互相信任建立借阅系统,同时鼓励每个人对所借书籍负责。 +

    +
    +
    +
  • +
+
+
+ + + + +

我们的特色

+
    +
  • +
    +
    + +
    +
    +
    "无储存"借阅模式
    +

    + 书籍在会员之间直接流转,无需集中存放,促进社区成员之间的直接交流。 +

    +
    +
    +
  • +
  • +
    +
    + +
    +
    +
    社区捐赠
    +

    + 所有书籍均来自社区成员的捐赠,体现了共享和互助的精神。 +

    +
    +
    +
  • +
  • +
    +
    + +
    +
    +
    线上管理
    +

    + 通过飞书多维表格进行书籍管理和借阅记录,方便透明。 +

    +
    +
    +
  • +
+
+
+ +
+ + + +

我们的团队

+

+ Open Library 由 freeCodeCamp + 成都社区的志愿者团队运营。我们的团队成员来自各行各业,但都有一个共同的目标:促进知识共享和社区建设。 +

+ + + + +
张伟
+

图书馆创始人

+ + + +
李梅
+

社区协调员

+ + + +
王晨
+

技术支持

+ +
+
+
+ + + +

加入我们

+

+ 如果你热爱阅读,愿意分享知识,欢迎加入 freeCodeCamp + 成都社区「Open Library」,成为知识流动的一部分! +

+

成为会员后,你可以:

+
    +
  • 借阅其他会员捐赠的书籍
  • +
  • 捐赠自己的书籍给社区
  • +
  • 参与社区组织的读书会和讨论
  • +
  • 结识志同道合的朋友
  • +
+ +
+
+
+
+
+ ); +} diff --git a/pages/open-library/book/[id].tsx b/pages/open-library/book/[id].tsx new file mode 100644 index 0000000..bf330a8 --- /dev/null +++ b/pages/open-library/book/[id].tsx @@ -0,0 +1,453 @@ +import { useRouter } from 'next/router'; +import React, { useEffect, useState } from 'react'; +import { Badge, Button, Card, Col, Row, Tab, Tabs } from 'react-bootstrap'; + +import { + ContentContainer, + Layout, +} from '../../../components/open-library/Layout'; + +// Book type definition +type Book = { + id: number; + title: string; + author: string; + cover?: string; + category: string; + language: string; + status: 'available' | 'borrowed'; + currentHolder?: string; + description?: string; + isbn?: string; + publisher?: string; + publishYear?: number; + pageCount?: number; + borrowHistory?: { + borrower: string; + borrowDate: string; + returnDate?: string; + }[]; + reviews?: { + reviewer: string; + rating: number; + comment: string; + date: string; + }[]; +}; + +// Mock database of books +const booksDatabase: Book[] = [ + { + id: 1, + title: 'Clean Code', + author: 'Robert C. Martin', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: + "A handbook of agile software craftsmanship. Even bad code can function. But if code isn't clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn't have to be that way.", + isbn: '9780132350884', + publisher: 'Prentice Hall', + publishYear: 2008, + pageCount: 464, + borrowHistory: [ + { + borrower: 'Wang Chen', + borrowDate: '2023-10-15', + returnDate: '2023-11-20', + }, + { + borrower: 'Li Mei', + borrowDate: '2023-08-01', + returnDate: '2023-09-05', + }, + ], + reviews: [ + { + reviewer: 'Wang Chen', + rating: 5, + comment: + 'This book completely changed how I approach writing code. Highly recommended for all developers!', + date: '2023-11-25', + }, + { + reviewer: 'Li Mei', + rating: 4, + comment: + 'Great principles that have stood the test of time. Some examples are a bit dated but the concepts are solid.', + date: '2023-09-10', + }, + ], + }, + { + id: 2, + title: 'Eloquent JavaScript', + author: 'Marijn Haverbeke', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'borrowed', + currentHolder: 'Zhang Wei', + description: + 'A modern introduction to programming. JavaScript lies at the heart of almost every modern web application, from social apps like Twitter to browser-based game frameworks like Phaser and Babylon. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.', + isbn: '9781593279509', + publisher: 'No Starch Press', + publishYear: 2018, + pageCount: 472, + borrowHistory: [ + { + borrower: 'Zhang Wei', + borrowDate: '2024-03-10', + }, + ], + reviews: [ + { + reviewer: 'Liu Jie', + rating: 5, + comment: + 'Perfect for beginners and intermediate JavaScript developers. The exercises are particularly helpful.', + date: '2023-12-05', + }, + ], + }, + { + id: 3, + title: 'Design Patterns', + author: 'Erich Gamma et al.', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: + 'Elements of Reusable Object-Oriented Software. Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems.', + isbn: '9780201633610', + publisher: 'Addison-Wesley Professional', + publishYear: 1994, + pageCount: 416, + borrowHistory: [ + { + borrower: 'Chen Ming', + borrowDate: '2023-06-15', + returnDate: '2023-07-20', + }, + ], + reviews: [ + { + reviewer: 'Chen Ming', + rating: 4, + comment: + 'A classic that has stood the test of time. The examples are in C++ and Smalltalk, but the concepts apply to any OO language.', + date: '2023-07-25', + }, + ], + }, + { + id: 4, + title: "You Don't Know JS", + author: 'Kyle Simpson', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: + 'A book series on JavaScript. This is a series of books diving deep into the core mechanisms of the JavaScript language.', + isbn: '9781491924464', + publisher: "O'Reilly Media", + publishYear: 2015, + pageCount: 278, + borrowHistory: [], + reviews: [], + }, + { + id: 5, + title: '深入理解计算机系统', + author: 'Randal E. Bryant', + cover: '/images/placeholder-book.svg', + category: 'Computer Science', + language: 'Chinese', + status: 'borrowed', + currentHolder: 'Li Mei', + description: + "Computer Systems: A Programmer's Perspective (Chinese Edition). This book introduces the important and enduring concepts that underlie computer systems.", + isbn: '9787111544937', + publisher: '机械工业出版社', + publishYear: 2016, + pageCount: 731, + borrowHistory: [ + { + borrower: 'Li Mei', + borrowDate: '2024-02-01', + }, + ], + reviews: [ + { + reviewer: 'Zhang Wei', + rating: 5, + comment: + '这是一本非常全面的计算机系统书籍,对理解计算机底层工作原理非常有帮助。', + date: '2023-10-15', + }, + ], + }, +]; + +export default function BookDetail() { + const router = useRouter(); + const { id } = router.query; + const [book, setBook] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + if (id) { + // In a real app, this would be an API call + const bookId = Array.isArray(id) + ? parseInt(id[0]) + : parseInt(id as string); + const foundBook = booksDatabase.find(b => b.id === bookId); + + setBook(foundBook || null); + setLoading(false); + } + }, [id]); + + if (loading) { + return ( + + +
+
+ Loading... +
+
+
+
+ ); + } + + if (!book) { + return ( + + +
+

Book Not Found

+

Sorry, we couldn't find the book you're looking for.

+ +
+
+
+ ); + } + + return ( + + +
+ + + + + + + {book.title} +
+ + {book.status === 'available' + ? 'Available' + : 'Currently Borrowed'} + +
+ {book.status === 'borrowed' && book.currentHolder && ( +
+ Current holder: {book.currentHolder} +
+ )} + + +

{book.title}

+
by {book.author}
+ +
+ + {book.category} + + + {book.language} + +
+ +

{book.description}

+ + + +
ISBN
+
{book.isbn || 'N/A'}
+ + +
Publisher
+
{book.publisher || 'N/A'}
+ + +
Published
+
{book.publishYear || 'N/A'}
+ + +
Pages
+
{book.pageCount || 'N/A'}
+ +
+ +
+ {book.status === 'available' ? ( + + ) : ( + + )} +
+ +
+
+
+ +
+ + + {book.reviews && book.reviews.length > 0 ? ( +
+ {book.reviews.map((review, index) => ( + + +
+
{review.reviewer}
+
+ {[...Array(5)].map((_, i) => ( + + {i < review.rating ? '\u2605' : '\u2606'} + + ))} +
+
+ {review.comment} + + + {new Date(review.date).toLocaleDateString()} + + +
+
+ ))} +
+ +
+
+ ) : ( +
+

+ No reviews yet. Be the first to review this book! +

+ +
+ )} +
+ + {book.borrowHistory && book.borrowHistory.length > 0 ? ( +
+ + + + + + + + + + + {book.borrowHistory.map((history, index) => ( + + + + + + + ))} + +
BorrowerBorrow DateReturn DateStatus
{history.borrower} + {new Date( + history.borrowDate, + ).toLocaleDateString()} + + {history.returnDate + ? new Date( + history.returnDate, + ).toLocaleDateString() + : '-'} + + {history.returnDate ? ( + Returned + ) : ( + + Active + + )} +
+
+ ) : ( +
+

This book has not been borrowed yet.

+
+ )} +
+
+
+
+
+
+ ); +} diff --git a/pages/open-library/books/index.tsx b/pages/open-library/books/index.tsx new file mode 100644 index 0000000..c18b6a0 --- /dev/null +++ b/pages/open-library/books/index.tsx @@ -0,0 +1,318 @@ +import React, { useEffect, useState } from 'react'; +import { + Button, + Card, + Col, + Form, + FormControl, + InputGroup, + Row, +} from 'react-bootstrap'; + +import { + ContentContainer, + Layout, +} from '../../../components/open-library/Layout'; + +// Book type definition +type Book = { + id: number; + title: string; + author: string; + cover?: string; + category: string; + language: string; + status: 'available' | 'borrowed'; + currentHolder?: string; + description?: string; +}; + +export default function BookCatalog() { + // Sample books data - in a real app, this would come from an API + const [books, setBooks] = useState([ + { + id: 1, + title: 'Clean Code', + author: 'Robert C. Martin', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: 'A handbook of agile software craftsmanship', + }, + { + id: 2, + title: 'Eloquent JavaScript', + author: 'Marijn Haverbeke', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'borrowed', + currentHolder: 'Zhang Wei', + description: 'A modern introduction to programming', + }, + { + id: 3, + title: 'Design Patterns', + author: 'Erich Gamma et al.', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: 'Elements of Reusable Object-Oriented Software', + }, + { + id: 4, + title: "You Don't Know JS", + author: 'Kyle Simpson', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'English', + status: 'available', + description: 'A book series on JavaScript', + }, + { + id: 5, + title: '深入理解计算机系统', + author: 'Randal E. Bryant', + cover: '/images/placeholder-book.svg', + category: 'Computer Science', + language: 'Chinese', + status: 'borrowed', + currentHolder: 'Li Mei', + description: + "Computer Systems: A Programmer's Perspective (Chinese Edition)", + }, + { + id: 6, + title: '算法导论', + author: 'Thomas H. Cormen et al.', + cover: '/images/placeholder-book.svg', + category: 'Computer Science', + language: 'Chinese', + status: 'available', + description: 'Introduction to Algorithms (Chinese Edition)', + }, + { + id: 7, + title: 'JavaScript高级程序设计', + author: 'Nicholas C. Zakas', + cover: '/images/placeholder-book.svg', + category: 'Programming', + language: 'Chinese', + status: 'available', + description: + 'Professional JavaScript for Web Developers (Chinese Edition)', + }, + { + id: 8, + title: 'CSS揭秘', + author: 'Lea Verou', + cover: '/images/placeholder-book.svg', + category: 'Web Development', + language: 'Chinese', + status: 'borrowed', + currentHolder: 'Wang Chen', + description: 'CSS Secrets (Chinese Edition)', + }, + ]); + + const [filteredBooks, setFilteredBooks] = useState(books); + const [searchTerm, setSearchTerm] = useState(''); + const [categoryFilter, setCategoryFilter] = useState(''); + const [languageFilter, setLanguageFilter] = useState(''); + const [statusFilter, setStatusFilter] = useState(''); + + // Extract unique categories and languages for filter dropdowns + const categories = [...new Set(books.map(book => book.category))]; + const languages = [...new Set(books.map(book => book.language))]; + + // Apply filters when any filter changes + useEffect(() => { + let results = books; + + // Apply search term filter + if (searchTerm) { + const term = searchTerm.toLowerCase(); + results = results.filter( + book => + book.title.toLowerCase().includes(term) || + book.author.toLowerCase().includes(term) || + (book.description && book.description.toLowerCase().includes(term)), + ); + } + + // Apply category filter + if (categoryFilter) { + results = results.filter(book => book.category === categoryFilter); + } + + // Apply language filter + if (languageFilter) { + results = results.filter(book => book.language === languageFilter); + } + + // Apply status filter + if (statusFilter) { + results = results.filter(book => book.status === statusFilter); + } + + setFilteredBooks(results); + }, [searchTerm, categoryFilter, languageFilter, statusFilter, books]); + + // Reset all filters + const resetFilters = () => { + setSearchTerm(''); + setCategoryFilter(''); + setLanguageFilter(''); + setStatusFilter(''); + }; + + return ( + + +

Book Catalog

+ + {/* Search and Filters */} + + + + + + setSearchTerm(e.target.value)} + /> + + + + + + + setCategoryFilter(e.target.value)} + > + + {categories.map(category => ( + + ))} + + + + setLanguageFilter(e.target.value)} + > + + {languages.map(language => ( + + ))} + + + + setStatusFilter(e.target.value)} + > + + + + + + + + +
+
+ + Showing {filteredBooks.length} of {books.length} books + +
+ +
+
+
+ + {/* Book Grid */} + + {filteredBooks.map(book => ( + + +
+ +
+ + {book.title} + + {book.author} + + + {book.description} + +
+
+ + {book.category} + + + {book.language} + +
+
+ + {book.status === 'available' ? 'Available' : 'Borrowed'} + + +
+ {book.status === 'borrowed' && ( +
+ Currently with: {book.currentHolder} +
+ )} +
+
+
+ + ))} +
+ + {/* No Results */} + {filteredBooks.length === 0 && ( +
+

No books found

+

Try adjusting your search or filters

+ +
+ )} +
+
+ ); +} diff --git a/pages/open-library/donate.tsx b/pages/open-library/donate.tsx new file mode 100644 index 0000000..7e54e0d --- /dev/null +++ b/pages/open-library/donate.tsx @@ -0,0 +1,254 @@ +import React from 'react'; +import { Button, Card, Col, Row } from 'react-bootstrap'; + +import { ContentContainer, Layout } from '../../components/open-library/Layout'; + +export default function DonatePage() { + return ( + + +
+

书籍募捐

+ + + +

为什么捐赠书籍?

+

+ 您的一本书,可能会改变他人的一生。通过捐赠书籍,您不仅能够让闲置的知识重新流动,还能够帮助更多的人获取学习资源。 +

+

+ 在 Open + Library,我们相信知识应该是流动的。您捐赠的每一本书都将在社区成员之间传递,让更多人受益。当您捐赠一本书,您不仅是在分享一个物品,更是在分享知识、经验和思想。 +

+
+
+ + + + + +

捐赠流程

+
    +
  1. +
    +
    填写捐赠申请
    +

    + 填写我们的在线表单,提供您想要捐赠的书籍信息。 +

    +
    +
  2. +
  3. +
    +
    书籍登记
    +

    + 如所捐赠书籍在「fCC + 成都社区图书馆」还未登记,请先填写书籍登记表,然后回到第 + 1 步继续捐赠。建议在移动端设备上登记,方便扫描书籍 + ISBN 码。 +

    +
    +
  4. +
  5. +
    +
    书籍进入图书馆
    +

    + 完成以上流程后,书籍正式进入 Open Library + 的传递流程,开始流转于社区成员之间。 +

    +
    +
  6. +
+ +
+
+ + + + +

书籍登记

+

+ 如果您要捐赠的书籍在我们的图书馆中还未登记,请先完成书籍登记流程。这有助于我们维护一个完整的书籍数据库,方便其他会员查找和借阅。 +

+

登记时,您需要提供以下信息:

+
    +
  • 书籍标题
  • +
  • 作者
  • +
  • ISBN(可通过扫描获取)
  • +
  • 出版社
  • +
  • 出版年份
  • +
  • 书籍类别
  • +
  • 书籍语言
  • +
  • 书籍简介
  • +
  • 书籍封面照片(可选)
  • +
+ +
+
+ +
+ + + +

我们接受什么样的书籍?

+ + +
✓ 我们欢迎
+
    +
  • 技术类书籍(编程、设计、数据科学等)
  • +
  • 科学类书籍
  • +
  • 商业和管理类书籍
  • +
  • 自我提升类书籍
  • +
  • 文学和小说
  • +
  • 状态良好的二手书
  • +
+ + +
✗ 不适合捐赠
+
    +
  • 严重破损或缺页的书籍
  • +
  • 有大量笔记或标记的书籍
  • +
  • 过时的技术书籍(5年以上的技术书可能已过时)
  • +
  • 教科书和习题集
  • +
  • 杂志和期刊
  • +
+ +
+
+
+ + + + +
+ + + +

常见问题

+
+
+

+ +

+
+
+ 您捐赠的书籍将进入我们的借阅系统,供社区成员借阅。当有人申请借阅时,书籍将从当前持有者(可能是您)直接传递给下一位借阅者。 +
+
+
+
+

+ +

+
+
+ 一旦书籍捐赠给图书馆,我们视为您已将书籍所有权转让给社区。如果您希望再次阅读这本书,可以通过正常的借阅流程申请借阅。 +
+
+
+
+

+ +

+
+
+ 您可以在我们的飞书多维表格中查看每本书的借阅记录,包括当前持有者和历史借阅情况。 +
+
+
+
+

+ +

+
+
+ 是的,我们要求捐赠者成为 Open Library + 的会员。这有助于我们建立一个基于信任的社区,并确保书籍的流转质量。 +
+
+
+
+
+ +
+
+ +
+

准备好捐赠书籍了吗?

+ +
+
+
+
+ ); +} diff --git a/pages/open-library/how-to-borrow.tsx b/pages/open-library/how-to-borrow.tsx new file mode 100644 index 0000000..451dfea --- /dev/null +++ b/pages/open-library/how-to-borrow.tsx @@ -0,0 +1,294 @@ +import React from 'react'; +import { Button, Card, Col, Row } from 'react-bootstrap'; + +import { ContentContainer, Layout } from '../../components/open-library/Layout'; + +export default function HowToBorrowPage() { + return ( + + +
+

如何借阅

+ + + +

借阅与传递模式

+

+ 在 Open Library,所有书籍均来自社区成员的捐赠,并由借阅者直接 + 传递给下一位借书人。 +

+

+ 我们采用的是一种独特的"无储存"借阅模式,让书籍在会员之间自由流转,而非集中存放。这种模式不仅节省了物理空间,更重要的是促进了社区成员之间的直接交流和互动。 +

+
+
+ + + + + +

借阅流程

+
+
+ +
+
+

1

+
+
+
查阅书籍
+

+ 社区成员可以在{' '} + + fCC 成都社区图书馆 + {' '} + 中查找自己感兴趣的书籍,或者在我们的{' '} + 书籍目录 中浏览。 +

+
+
+ +
+
+

2

+
+
+
申请借阅
+

+ 找到心仪的书籍后,填写{' '} + + fCC 成都社区图书馆-书籍借入 + {' '} + 申请,与当前持书者取得联系。 +

+
+
+ +
+
+

3

+
+
+
线下传递
+

+ 双方约定时间和传递方式,通常可用快递传递书籍。请传递者填写{' '} + + fCC 成都社区图书馆-书籍传递 + + ,再将书籍传递出去。 +

+
+
+ +
+
+

4

+
+
+
阅读与分享
+

+ 借阅者在阅读完毕后,可以分享自己的阅读感悟,并在社区推荐给下一位感兴趣的成员。我们鼓励借阅者在归还前写下简短的书评。 +

+
+
+ +
+
+

5

+
+
+
继续传递
+

+ 当有新的借阅者申请时,当前持书人将书籍传递给下一位读者,确保知识的持续流动。 +

+
+
+
+
+
+ + + + +

借阅规则

+
    +
  • + 借阅期限: 每本书的标准借阅期为 30 + 天,如需延长可与图书馆管理员联系。 +
  • +
  • + 借阅数量: 每位会员同时最多可借阅 3 + 本书。 +
  • +
  • + 书籍状态:{' '} + 借阅者有责任保持书籍的良好状态,避免损坏、标记或丢失。 +
  • +
  • + 传递责任:{' '} + 当前持书人负责将书籍安全传递给下一位借阅者,并承担相关的传递费用。 +
  • +
  • + 丢失或损坏:{' '} + 如果书籍在您借阅期间丢失或严重损坏,请联系图书馆管理员并考虑捐赠一本相同或类似的书籍作为替代。 +
  • +
+
+
+ + + +

快速链接

+ +
+
+ +
+ + + +

常见问题解答

+ + +
如何知道一本书是否可借?
+

+ 您可以在飞书多维表格或我们的网站书籍目录中查看书籍的当前状态。如果标记为"可借阅",则表示该书可以申请借阅。 +

+ + +
我需要支付借阅费用吗?
+

+ Open Library + 不收取借阅费用,但借阅者需要承担书籍传递的相关费用(如快递费)。 +

+ + +
如果当前没有人申请借我手中的书,我需要归还吗?
+

+ 标准借阅期为 30 + 天。如果期满后没有新的借阅申请,您可以继续保留该书,但请随时准备传递给下一位申请者。 +

+ + +
如何联系当前持书人?
+

+ 当您提交借阅申请后,我们会为您提供当前持书人的联系方式,以便您们协商传递事宜。 +

+ + +
如果我想长期保留一本书怎么办?
+

+ Open Library + 的宗旨是促进知识流动,我们鼓励书籍在会员之间传递。如果您特别喜欢某本书,建议购买一本自己的副本,或者考虑捐赠一本相同的书籍给图书馆。 +

+ + +
我可以借阅电子书吗?
+

+ 目前 Open Library + 主要提供实体书的借阅服务。我们正在考虑未来增加电子书资源,敬请期待。 +

+ +
+
+
+ +
+

准备好借阅了吗?

+ +
+
+
+
+ ); +} diff --git a/pages/open-library/index.tsx b/pages/open-library/index.tsx index 074b5e7..5853be1 100644 --- a/pages/open-library/index.tsx +++ b/pages/open-library/index.tsx @@ -1,8 +1,9 @@ import Link from 'next/link'; -import React, { useEffect } from 'react'; +import React from 'react'; import { Button, Card, Col, Form, Image, Row, Stack } from 'react-bootstrap'; import { ContentContainer, Layout } from '../../components/open-library/Layout'; +import { t } from '../../models/Translation'; // TODO: Define a type for Book and Testimonial type Book = { @@ -69,160 +70,8 @@ export default function OpenLibraryHomepage() { }, ]; - // Use client-side code to hide the main site header and adjust layout - useEffect(() => { - // Function to apply style to an element - const applyStyle = ( - element: HTMLElement | null, - styles: Partial, - ) => { - if (!element) return; - - Object.entries(styles).forEach(([property, value]) => { - if (value) { - // @ts-expect-error: dynamic property assignment - element.style[property] = value; - } - }); - }; - - // Hide the main site header - const mainHeader = document.querySelector( - 'nav.navbar.bg-dark.navbar-dark.fixed-top', - ); - applyStyle(mainHeader as HTMLElement, { display: 'none' }); - - // Remove top margin that accommodates the main header - const mainContent = document.querySelector('div.mt-5.pt-2'); - applyStyle(mainContent as HTMLElement, { - marginTop: '0', - paddingTop: '0', - maxWidth: '100%', - width: '100%', - }); - - // Remove background and padding from main content - const mainWrapper = document.querySelector( - 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', - ); - applyStyle(mainWrapper as HTMLElement, { - background: 'none', - padding: '0', - margin: '0', - maxWidth: '100%', - width: '100%', - }); - - // Remove container constraints - const containers = document.querySelectorAll('.container'); - containers.forEach(container => { - applyStyle(container as HTMLElement, { - maxWidth: '100%', - padding: '0', - margin: '0', - }); - }); - - // Remove card styling - const cards = document.querySelectorAll('.card'); - cards.forEach(card => { - if ( - card.closest( - 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', - ) - ) { - applyStyle(card as HTMLElement, { - background: 'transparent', - border: 'none', - boxShadow: 'none', - padding: '0', - margin: '0', - }); - } - }); - - // Remove card body padding - const cardBodies = document.querySelectorAll('.card-body'); - cardBodies.forEach(cardBody => { - if ( - cardBody.closest( - 'main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center', - ) - ) { - applyStyle(cardBody as HTMLElement, { - padding: '0', - }); - } - }); - - // Hide the main site footer - const mainFooter = document.querySelector( - 'footer.mw-100.bg-dark.text-white', - ); - applyStyle(mainFooter as HTMLElement, { display: 'none' }); - - // Remove all padding and margin from body and html - applyStyle(document.body, { - margin: '0', - padding: '0', - overflow: 'auto', - }); - - applyStyle(document.documentElement, { - margin: '0', - padding: '0', - overflow: 'auto', - }); - - // Target the MDXProvider wrapper (main white background) - const mdxProvider = document.querySelector(`.MDXProvider`); - applyStyle(mdxProvider as HTMLElement, { - padding: '0 !important', - margin: '0 !important', - background: 'transparent !important', - border: 'none !important', - boxShadow: 'none !important', - }); - - // Add custom styles to ensure full width - const style = document.createElement('style'); - style.textContent = ` - body, html { - margin: 0 !important; - padding: 0 !important; - overflow-x: hidden !important; - } - .container, .container-fluid { - max-width: 100% !important; - padding-left: 0 !important; - padding-right: 0 !important; - margin-left: 0 !important; - margin-right: 0 !important; - } - main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center { - padding: 0 !important; - margin: 0 !important; - max-width: 100% !important; - width: 100% !important; - } - main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center > .container { - max-width: 100% !important; - padding: 0 !important; - margin: 0 !important; - } - .MDXProvider { - padding: 0 !important; - margin: 0 !important; - background: transparent !important; - border: none !important; - box-shadow: none !important; - } - `; - document.head.appendChild(style); - }, []); - return ( - +
{/* --- Hero Section --- */}
-

- Free knowledge flows here -

-

- Share and borrow books in our open-source community. Join - freeCodeCamp Chengdu's initiative to make learning accessible - to everyone. -

+

{t('hero_title')}

+

{t('hero_subtitle')}

{/* TODO: Link this button to the actual Feishu form or member sign-up page */} - @@ -265,9 +114,11 @@ export default function OpenLibraryHomepage() { {/* --- Featured Books Section --- */}
-

Featured Books

+

+ {t('featured_books')} +

- Discover what our community is reading right now + {t('featured_books_subtitle')}

{featuredBooks.map(book => ( @@ -299,7 +150,7 @@ export default function OpenLibraryHomepage() { legacyBehavior > @@ -314,7 +165,7 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Browse All Books + {t('view_all_books')} → @@ -326,14 +177,10 @@ export default function OpenLibraryHomepage() { -

Share Your Knowledge

-

- Have books collecting dust on your shelf? Donate them to our - community and help others learn and grow. Your contribution - makes a difference! -

+

{t('share_your_knowledge')}

+

{t('donation_callout_subtitle')}

- + @@ -353,40 +200,31 @@ export default function OpenLibraryHomepage() { {/* --- How It Works Section --- */}
-

How It Works

+

{t('how_it_works')}

- Three simple steps to borrow books from our community + {t('how_it_works_description')}

-

1. Find a Book

-

- Browse our collection and find the book that interests you. - Filter by category, author, or popularity. -

+

{t('step_1_find_book')}

+

{t('step_1_description')}

-

2. Apply to Borrow

-

- Submit a simple request form. We'll connect you with the book - owner and arrange the handover. -

+

{t('step_2_apply')}

+

{t('step_2_description')}

-

3. Receive and Pass It On

-

- Enjoy your book and return it when you're done. Consider - donating your own books to keep knowledge flowing. -

+

{t('step_3_receive')}

+

{t('step_3_description')}

@@ -395,7 +233,7 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Learn More About Borrowing + {t('learn_more_about_borrowing')}
@@ -405,9 +243,11 @@ export default function OpenLibraryHomepage() { {/* --- Testimonials Section --- */}
-

Community Voices

+

+ {t('community_voices')} +

- What our members say about Open Library + {t('community_voices_description')}

{testimonials.map(testimonial => ( @@ -431,7 +271,7 @@ export default function OpenLibraryHomepage() { variant="link" className="text-success text-decoration-none" > - Read More Reviews + {t('read_more_reviews')} @@ -445,10 +285,9 @@ export default function OpenLibraryHomepage() { -

Stay Updated

+

{t('stay_updated')}

- Subscribe to our newsletter for new book arrivals and - community events. + {t('newsletter_description')}

{/* TODO: Implement actual newsletter subscription logic */}
e.preventDefault()}> @@ -462,11 +301,11 @@ export default function OpenLibraryHomepage() { > diff --git a/pages/open-library/review.tsx b/pages/open-library/review.tsx new file mode 100644 index 0000000..28222cf --- /dev/null +++ b/pages/open-library/review.tsx @@ -0,0 +1,372 @@ +import React, { useState } from 'react'; +import { Button, Card, Col, Form, Row, Tab, Tabs } from 'react-bootstrap'; + +import { ContentContainer, Layout } from '../../components/open-library/Layout'; + +// Review type definition +type Review = { + id: number; + bookTitle: string; + bookAuthor: string; + bookCover?: string; + reviewer: string; + rating: number; + comment: string; + date: string; +}; + +export default function ReviewPage() { + // Sample reviews data - in a real app, this would come from an API + const [reviews, setReviews] = useState([ + { + id: 1, + bookTitle: 'Clean Code', + bookAuthor: 'Robert C. Martin', + bookCover: '/images/placeholder-book.svg', + reviewer: 'Wang Chen', + rating: 5, + comment: + 'This book completely changed how I approach writing code. Highly recommended for all developers!', + date: '2023-11-25', + }, + { + id: 2, + bookTitle: 'Clean Code', + bookAuthor: 'Robert C. Martin', + bookCover: '/images/placeholder-book.svg', + reviewer: 'Li Mei', + rating: 4, + comment: + 'Great principles that have stood the test of time. Some examples are a bit dated but the concepts are solid.', + date: '2023-09-10', + }, + { + id: 3, + bookTitle: 'Eloquent JavaScript', + bookAuthor: 'Marijn Haverbeke', + bookCover: '/images/placeholder-book.svg', + reviewer: 'Liu Jie', + rating: 5, + comment: + 'Perfect for beginners and intermediate JavaScript developers. The exercises are particularly helpful.', + date: '2023-12-05', + }, + { + id: 4, + bookTitle: 'Design Patterns', + bookAuthor: 'Erich Gamma et al.', + bookCover: '/images/placeholder-book.svg', + reviewer: 'Chen Ming', + rating: 4, + comment: + 'A classic that has stood the test of time. The examples are in C++ and Smalltalk, but the concepts apply to any OO language.', + date: '2023-07-25', + }, + { + id: 5, + bookTitle: '深入理解计算机系统', + bookAuthor: 'Randal E. Bryant', + bookCover: '/images/placeholder-book.svg', + reviewer: 'Zhang Wei', + rating: 5, + comment: + '这是一本非常全面的计算机系统书籍,对理解计算机底层工作原理非常有帮助。', + date: '2023-10-15', + }, + ]); + + // Function to render star rating + const renderStars = (rating: number) => { + return ( +
+ {[...Array(5)].map((_, i) => ( + + {i < rating ? '\u2605' : '\u2606'} + + ))} +
+ ); + }; + + return ( + + +
+

书籍评价

+ + + +

社区书评

+

+ 阅读是一种体验,分享让这种体验更加丰富。浏览社区成员的书评,或者分享您自己的阅读感受。 +

+
+ +
+
+
+ + + +
+ {reviews.map(review => ( + + + + +
+ {review.bookTitle} +
{review.bookTitle}
+

+ {review.bookAuthor} +

+
+ + +
+
{review.reviewer}
+ {renderStars(review.rating)} +
+

{review.comment}

+
+ + {new Date(review.date).toLocaleDateString( + 'en-US', + { + year: 'numeric', + month: '2-digit', + day: '2-digit', + }, + )} + + +
+ +
+
+
+ ))} +
+
+ +
+ {reviews + .sort( + (a, b) => + new Date(b.date).getTime() - new Date(a.date).getTime(), + ) + .slice(0, 3) + .map(review => ( + + + + +
+ {review.bookTitle} +
+ {review.bookTitle} +
+

+ {review.bookAuthor} +

+
+ + +
+
{review.reviewer}
+ {renderStars(review.rating)} +
+

{review.comment}

+
+ + {new Date(review.date).toLocaleDateString( + 'en-US', + { + year: 'numeric', + month: '2-digit', + day: '2-digit', + }, + )} + + +
+ +
+
+
+ ))} +
+
+ +
+ {reviews + .filter(review => review.rating >= 5) + .map(review => ( + + + + +
+ {review.bookTitle} +
+ {review.bookTitle} +
+

+ {review.bookAuthor} +

+
+ + +
+
{review.reviewer}
+ {renderStars(review.rating)} +
+

{review.comment}

+
+ + {new Date(review.date).toLocaleDateString( + 'en-US', + { + year: 'numeric', + month: '2-digit', + day: '2-digit', + }, + )} + + +
+ +
+
+
+ ))} +
+
+
+ + + +

写下您的书评

+

+ 阅读完一本书后,请花几分钟时间分享您的阅读体验。您的评价将帮助其他社区成员找到适合他们的书籍。 +

+
+ +
+
+
+ + + +

书评指南

+ + +
如何写一篇有帮助的书评
+
    +
  • 简要概述书籍内容,但不要透露关键情节
  • +
  • 分享您从书中获得的主要收获
  • +
  • 提及书籍的优点和可能的缺点
  • +
  • 说明适合阅读这本书的人群
  • +
  • 分享书中让您印象深刻的观点或引用
  • +
+ + +
评分参考
+
    +
  • +
    +
    ★★★★★
    +
    杰出,强烈推荐,改变思维的书籍
    +
    +
  • +
  • +
    +
    ★★★★☆
    +
    非常好,值得推荐,有一些小缺点
    +
    +
  • +
  • +
    +
    ★★★☆☆
    +
    好,有价值,但不突出
    +
    +
  • +
  • +
    +
    ★★☆☆☆
    +
    一般,有一些有用信息,但整体平淡
    +
    +
  • +
  • +
    +
    ★☆☆☆☆
    +
    不推荐,内容质量较低或不准确
    +
    +
  • +
+ +
+
+
+
+
+
+ ); +} diff --git a/styles/open-library.css b/styles/open-library.css new file mode 100644 index 0000000..540c4bd --- /dev/null +++ b/styles/open-library.css @@ -0,0 +1,65 @@ +/* Open Library Global Styles */ + +/* Reset styles for Open Library section */ +body.open-library, +html.open-library { + margin: 0 !important; + padding: 0 !important; + overflow-x: hidden !important; +} + +/* Hide main site header and footer */ +body.open-library nav.navbar.bg-dark.navbar-dark.fixed-top, +body.open-library footer.mw-100.bg-dark.text-white { + display: none !important; +} + +/* Remove top margin that accommodates the main header */ +body.open-library div.mt-5.pt-2 { + margin-top: 0 !important; + padding-top: 0 !important; + max-width: 100% !important; + width: 100% !important; +} + +/* Adjust main wrapper */ +body.open-library main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center { + background: none !important; + padding: 0 !important; + margin: 0 !important; + max-width: 100% !important; + width: 100% !important; +} + +/* Adjust container styles */ +body.open-library .container, +body.open-library .container-fluid { + max-width: 100% !important; + padding-left: 0 !important; + padding-right: 0 !important; + margin-left: 0 !important; + margin-right: 0 !important; +} + +/* Remove card styling from main content */ +body.open-library main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center .card { + background: transparent !important; + border: none !important; + box-shadow: none !important; + padding: 0 !important; + margin: 0 !important; +} + +/* Remove card body padding */ +body.open-library main.flex-fill.d-flex.flex-column.justify-content-start.align-items-center .card-body { + padding: 0 !important; +} + +/* Target the MDXProvider wrapper (main white background) */ +body.open-library .MDXProvider { + padding: 0 !important; + margin: 0 !important; + background: transparent !important; + border: none !important; + box-shadow: none !important; +} diff --git a/translation/en-US.ts b/translation/en-US.ts index 7e0ac36..fa87442 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -13,5 +13,152 @@ export default { search_results: 'Search Results', // Open Library - open_library: "Open Library", + open_library: 'Open Library', + + // Open Library Navigation + home: 'Home', + catalog: 'Catalog', + donate: 'Donate', + how_to_borrow: 'How to Borrow', + review: 'Review', + + // Open Library Home Page + featured_books: 'Featured Books', + view_all_books: 'Browse All Books', + browse_catalog: 'Browse Catalog', + testimonials: 'Testimonials', + join_community: 'Join Our Community', + become_member: 'Become a Member', + donate_books: 'Donate Books', + how_it_works: 'How It Works', + how_it_works_description: + 'Three simple steps to borrow books from our community', + step_1_find_book: '1. Find a Book', + step_1_description: + 'Browse our collection and find the book that interests you. Filter by category, author, or popularity.', + step_2_apply: '2. Apply to Borrow', + step_2_description: + "Submit a simple request form. We'll connect you with the book owner and arrange the handover.", + step_3_receive: '3. Receive and Pass It On', + step_3_description: + "Enjoy your book and return it when you're done. Consider donating your own books to keep knowledge flowing.", + learn_more_about_borrowing: 'Learn More About Borrowing', + community_voices: 'Community Voices', + community_voices_description: 'What our members say about Open Library', + read_more_reviews: 'Read More Reviews', + share_your_knowledge: 'Share Your Knowledge', + donate_a_book: 'Donate a Book', + stay_updated: 'Stay Updated', + newsletter_description: + 'Subscribe to our newsletter for new book arrivals and community events.', + email_placeholder: 'Your email address', + subscribe: 'Subscribe', + + // Open Library Books Page + book_catalog: 'Book Catalog', + search_books: 'Search Books', + all_categories: 'All Categories', + all_languages: 'All Languages', + all_status: 'All Status', + available: 'Available', + borrowed: 'Borrowed', + reset_filters: 'Reset Filters', + showing_books: 'Showing {0} of {1} books', + no_books_found: 'No books found', + try_adjusting_filters: 'Try adjusting your search or filters', + reset_all_filters: 'Reset All Filters', + view_details: 'View Details', + currently_with: 'Currently with: {0}', + + // Open Library Book Detail Page + loading: 'Loading...', + book_not_found: 'Book Not Found', + return_to_catalog: 'Return to Catalog', + back: 'Back', + by_author: 'by {0}', + currently_borrowed: 'Currently Borrowed', + currently_unavailable: 'Currently Unavailable', + request_to_borrow: 'Request to Borrow', + reviews: 'Reviews', + borrow_history: 'Borrow History', + no_reviews_yet: 'No reviews yet', + be_first_to_review: 'Be the first to review this book!', + write_review: 'Write a Review', + add_your_review: 'Add Your Review', + borrower: 'Borrower', + borrow_date: 'Borrow Date', + return_date: 'Return Date', + status: 'Status', + returned: 'Returned', + active: 'Active', + not_borrowed_yet: 'This book has not been borrowed yet', + + // Open Library About Page + about_open_library: 'About Open Library', + our_mission: 'Our Mission', + our_values: 'Our Values', + our_features: 'Our Features', + our_team: 'Our Team', + join_us_open_library: 'Join Us', + + // Open Library Donate Page + book_donation: 'Book Donation', + why_donate: 'Why Donate Books?', + donation_process: 'Donation Process', + book_registration: 'Book Registration', + what_books_we_accept: 'What Books Do We Accept?', + we_welcome: 'We Welcome', + not_suitable: 'Not Suitable for Donation', + faq: 'Frequently Asked Questions', + ready_to_donate: 'Ready to Donate Books?', + fill_donation_form: 'Fill Donation Form', + apply_for_membership: 'Apply for Membership', + + // Open Library How to Borrow Page + how_to_borrow_page: 'How to Borrow', + borrowing_and_passing: 'Borrowing and Passing Model', + borrowing_process: 'Borrowing Process', + borrowing_rules: 'Borrowing Rules', + quick_links: 'Quick Links', + view_full_catalog: 'View Full Catalog', + fill_borrow_request: 'Fill Borrow Request', + fill_book_passing_form: 'Fill Book Passing Form', + browse_book_catalog: 'Browse Book Catalog', + + // Open Library Review Page + book_reviews: 'Book Reviews', + community_reviews: 'Community Reviews', + all_reviews: 'All Reviews', + recent_reviews: 'Recent Reviews', + top_reviews: 'Top Reviews', + write_your_review: 'Write Your Review', + review_guidelines: 'Review Guidelines', + how_to_write_helpful_review: 'How to Write a Helpful Review', + rating_reference: 'Rating Reference', + + // Homepage Hero Section + hero_title: 'Free knowledge flows here', + hero_subtitle: + "Share and borrow books in our open-source community. Join freeCodeCamp Chengdu's initiative to make learning accessible to everyone.", + + // Featured Books Section + featured_books_subtitle: 'Discover what our community is reading right now', + + // Donation Callout Section + donation_callout_subtitle: + 'Have books collecting dust on your shelf? Donate them to our community and help others learn and grow. Your contribution makes a difference!', + + // Footer + footer_description: + 'A community-driven library for sharing knowledge and stories. Built with open source. Powered by generosity.', + quick_links_footer: 'Quick Links', + home_footer: 'Home', + catalog_footer: 'Catalog', + about_us_footer: 'About Us', + donate_footer: 'Donate', + contact: 'Contact', + contact_email: 'Email: info@openlibrary.community', + contact_address: 'Address: 123 Library Lane, Knowledge City, World', + follow_us: 'Follow Us', + all_rights_reserved: 'All Rights Reserved', }; diff --git a/translation/zh-CN.ts b/translation/zh-CN.ts index 44edfe7..35e7ebc 100644 --- a/translation/zh-CN.ts +++ b/translation/zh-CN.ts @@ -13,5 +13,149 @@ export default { search_results: '搜索结果', // Open Library - open_library: "开源图书馆", + open_library: '开源图书馆', + + // Open Library Navigation + home: '首页', + catalog: '书籍目录', + donate: '书籍募捐', + how_to_borrow: '如何借阅', + review: '书籍评价', + + // Open Library Home Page + featured_books: '精选书籍', + view_all_books: '浏览全部书籍', + browse_catalog: '浏览书目', + testimonials: '读者反馈', + join_community: '加入社区', + become_member: '成为会员', + donate_books: '捐赠书籍', + how_it_works: '运作方式', + how_it_works_description: '三个简单步骤借阅社区书籍', + step_1_find_book: '1. 寻找书籍', + step_1_description: + '浏览我们的藏书并找到您感兴趣的书籍。可按类别、作者或热度筛选。', + step_2_apply: '2. 申请借阅', + step_2_description: '提交简单的申请表。我们将为您联系书籍所有者并安排交接。', + step_3_receive: '3. 接收并传递', + step_3_description: + '阅读完毕后归还书籍。考虑捐赠您自己的书籍,让知识持续流动。', + learn_more_about_borrowing: '了解更多借阅信息', + community_voices: '社区声音', + community_voices_description: '会员对开源图书馆的评价', + read_more_reviews: '阅读更多评价', + share_your_knowledge: '分享您的知识', + donate_a_book: '捐赠一本书', + stay_updated: '保持更新', + newsletter_description: '订阅我们的通讯,获取新书到达和社区活动信息。', + email_placeholder: '您的电子邮箱', + subscribe: '订阅', + + // Open Library Books Page + book_catalog: '书籍目录', + search_books: '搜索书籍', + all_categories: '所有分类', + all_languages: '所有语言', + all_status: '所有状态', + available: '可借阅', + borrowed: '已借出', + reset_filters: '重置筛选', + showing_books: '显示 {0} 本书,共 {1} 本', + no_books_found: '未找到书籍', + try_adjusting_filters: '尝试调整筛选条件', + reset_all_filters: '重置所有筛选', + view_details: '查看详情', + currently_with: '当前持有者: {0}', + + // Open Library Book Detail Page + loading: '加载中...', + book_not_found: '未找到书籍', + return_to_catalog: '返回目录', + back: '返回', + by_author: '作者: {0}', + currently_borrowed: '当前已借出', + currently_unavailable: '当前不可用', + request_to_borrow: '申请借阅', + reviews: '评价', + borrow_history: '借阅历史', + no_reviews_yet: '暂无评价', + be_first_to_review: '成为第一个评价的人!', + write_review: '写评价', + add_your_review: '添加您的评价', + borrower: '借阅者', + borrow_date: '借阅日期', + return_date: '归还日期', + status: '状态', + returned: '已归还', + active: '借阅中', + not_borrowed_yet: '此书尚未被借阅过', + + // Open Library About Page + about_open_library: '关于社区图书馆', + our_mission: '我们的使命', + our_values: '我们的价值观', + our_features: '我们的特色', + our_team: '我们的团队', + join_us_open_library: '加入我们', + + // Open Library Donate Page + book_donation: '书籍募捐', + why_donate: '为什么捐赠书籍?', + donation_process: '捐赠流程', + book_registration: '书籍登记', + what_books_we_accept: '我们接受什么样的书籍?', + we_welcome: '我们欢迎', + not_suitable: '不适合捐赠', + faq: '常见问题', + ready_to_donate: '准备好捐赠书籍了吗?', + fill_donation_form: '填写捐赠申请', + apply_for_membership: '申请成为会员', + + // Open Library How to Borrow Page + how_to_borrow_page: '如何借阅', + borrowing_and_passing: '借阅与传递模式', + borrowing_process: '借阅流程', + borrowing_rules: '借阅规则', + quick_links: '快速链接', + view_full_catalog: '查看完整书籍目录', + fill_borrow_request: '填写借阅申请', + fill_book_passing_form: '填写书籍传递表', + browse_book_catalog: '浏览书籍目录', + + // Open Library Review Page + book_reviews: '书籍评价', + community_reviews: '社区书评', + all_reviews: '所有评价', + recent_reviews: '最新评价', + top_reviews: '高分评价', + write_your_review: '写下您的书评', + review_guidelines: '书评指南', + how_to_write_helpful_review: '如何写一篇有帮助的书评', + rating_reference: '评分参考', + + // Homepage Hero Section + hero_title: '知识在这里自由流动', + hero_subtitle: + '在我们的开源社区中分享和借阅书籍。加入 freeCodeCamp 成都社区的倡议,让学习对每个人都触手可及。', + + // Featured Books Section + featured_books_subtitle: '发现我们社区现在正在阅读的书籍', + + // Donation Callout Section + donation_callout_subtitle: + '您的书架上有积灰的书吗?将它们捐赠给我们的社区,帮助他人学习和成长。您的贡献会产生影响!', + + // Footer + footer_description: + '一个由社区驱动的图书馆,用于分享知识和故事。开源构建。由慷慨驱动。', + quick_links_footer: '快速链接', + home_footer: '首页', + catalog_footer: '目录', + about_us_footer: '关于我们', + donate_footer: '捐赠', + contact: '联系我们', + contact_email: '邮箱:info@openlibrary.community', + contact_address: '地址:123 图书馆路,知识城,世界', + follow_us: '关注我们', + all_rights_reserved: '版权所有', }; diff --git a/translation/zh-TW.ts b/translation/zh-TW.ts index be691cc..ba0dc09 100644 --- a/translation/zh-TW.ts +++ b/translation/zh-TW.ts @@ -13,5 +13,148 @@ export default { search_results: '搜尋結果', // Open Library - open_library: "開源圖書館", + open_library: '開源圖書館', + + // Open Library Navigation + home: '首頁', + catalog: '目錄', + donate: '捐贈', + how_to_borrow: '如何借書', + review: '書評', + + // Open Library Home Page + featured_books: '特色書籍', + view_all_books: '查看所有書籍', + browse_catalog: '瀏覽目錄', + testimonials: '證言', + join_community: '加入社群', + become_member: '成為會員', + donate_books: '捐贈書籍', + how_it_works: '如何運作', + how_it_works_description: '九步驟加入社群圖書館', + step_1_find_book: '1. 找書', + step_1_description: + '瀏覽我們的書籍目錄,找到您想要的書籍。您可以按類別、作者或標題搜索。', + step_2_apply: '2. 申請借書', + step_2_description: '填寫借書申請表格,我們會與您聯絡安排借書事宜。', + step_3_receive: '3. 收書', + step_3_description: '書籍將會寄送到您指定的地址,請注意查收。', + learn_more_about_borrowing: '了解更多借書資訊', + community_voices: '社群聲音', + community_voices_description: '聽聽我們的社群成員怎麼說', + read_more_reviews: '閱讀更多書評', + share_your_knowledge: '分享您的知識', + donate_a_book: '捐贈一本書', + stay_updated: '保持更新', + newsletter_description: '訂閱我們的電子報,保持與社群圖書館的聯絡。', + email_placeholder: '您的電子郵件地址', + subscribe: '訂閱', + + // Open Library Books Page + book_catalog: '書籍目錄', + search_books: '搜尋書籍', + all_categories: '所有類別', + all_languages: '所有語言', + all_status: '所有狀態', + available: '可借', + borrowed: '已借出', + reset_filters: '重設篩選', + showing_books: '顯示 {0} 本書,共 {1} 本', + no_books_found: '沒有找到書籍', + try_adjusting_filters: '試著調整篩選條件', + reset_all_filters: '重設所有篩選', + view_details: '查看詳情', + currently_with: '目前由 {0} 借出', + + // Open Library Book Detail Page + loading: '載入中...', + book_not_found: '沒有找到書籍', + return_to_catalog: '返回目錄', + back: '返回', + by_author: '作者:{0}', + currently_borrowed: '目前已借出', + currently_unavailable: '目前不可借', + request_to_borrow: '申請借書', + reviews: '書評', + borrow_history: '借書歷史', + no_reviews_yet: '尚無書評', + be_first_to_review: '成為第一個書評的人!', + write_review: '寫書評', + add_your_review: '新增您的書評', + borrower: '借書人', + borrow_date: '借書日期', + return_date: '歸還日期', + status: '狀態', + returned: '已歸還', + active: '借書中', + not_borrowed_yet: '尚未借出', + + // Open Library About Page + about_open_library: '關於開源圖書館', + our_mission: '我們的使命', + our_values: '我們的價值', + our_features: '我們的特色', + our_team: '我們的團隊', + join_us_open_library: '加入我們', + + // Open Library Donate Page + book_donation: '書籍捐贈', + why_donate: '為什麼捐贈?', + donation_process: '捐贈流程', + book_registration: '書籍登錄', + what_books_we_accept: '我們接受什麼書籍?', + we_welcome: '我們歡迎', + not_suitable: '不適合', + faq: '常見問題', + ready_to_donate: '準備捐贈書籍?', + fill_donation_form: '填寫捐贈表單', + apply_for_membership: '申請會員', + + // Open Library How to Borrow Page + how_to_borrow_page: '如何借書', + borrowing_and_passing: '借閱與傳遞模式', + borrowing_process: '借書流程', + borrowing_rules: '借書規則', + quick_links: '快速連結', + view_full_catalog: '查看完整目錄', + fill_borrow_request: '填寫借書申請', + fill_book_passing_form: '填寫書籍傳遞表單', + browse_book_catalog: '瀏覽書籍目錄', + + // Open Library Review Page + book_reviews: '書籍書評', + community_reviews: '社群書評', + all_reviews: '所有書評', + recent_reviews: '最新書評', + top_reviews: '最佳書評', + write_your_review: '寫您的書評', + review_guidelines: '書評指南', + how_to_write_helpful_review: '如何寫有用的書評', + rating_reference: '評分參考', + + // Homepage Hero Section + hero_title: '在我們的開源圖書館中探索', + hero_subtitle: + '在我們的社群圖書館中探索免費的書籍和資源。加入 freeCodeCamp 成為社群圖書館的一部分,學習和分享知識。', + + // Featured Books Section + featured_books_subtitle: '我們社群圖書館中最受歡迎的書籍', + + // Donation Callout Section + donation_callout_subtitle: + '您的捐贈將有助於我們的社群圖書館的發展。您的支持將有助於我們提供更多免費的書籍和資源給社群成員。', + + // Footer + footer_description: + '一個開源的社群圖書館,提供免費的書籍和資源給社群成員。開源。免費。無限可能。', + quick_links_footer: '快速連結', + home_footer: '首頁', + catalog_footer: '目錄', + about_us_footer: '關於我們', + donate_footer: '捐贈', + contact: '聯絡我們', + contact_email: '聯絡郵件:info@openlibrary.community', + contact_address: '地址:123 圖書館路,社群圖書館,香港', + follow_us: '關注我們', + all_rights_reserved: '版權所有', }; From 23870d8e610d79e33acf509fb18e85e2e4c6dba3 Mon Sep 17 00:00:00 2001 From: dethan3 Date: Fri, 25 Apr 2025 14:22:20 +0800 Subject: [PATCH 6/7] fix: replace tags with Next.js components and fix TypeScript errors --- components/open-library/Navbar.tsx | 2 +- pages/open-library/books/index.tsx | 4 ++-- pages/open-library/how-to-borrow.tsx | 20 ++++++++++++-------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx index 1b2fd35..c870c9a 100644 --- a/components/open-library/Navbar.tsx +++ b/components/open-library/Navbar.tsx @@ -1,6 +1,6 @@ import dynamic from 'next/dynamic'; import React from 'react'; -import { Button, Form, FormControl, Nav, Navbar } from 'react-bootstrap'; +import { Nav, Navbar } from 'react-bootstrap'; import { t } from '../../models/Translation'; diff --git a/pages/open-library/books/index.tsx b/pages/open-library/books/index.tsx index c18b6a0..f46f708 100644 --- a/pages/open-library/books/index.tsx +++ b/pages/open-library/books/index.tsx @@ -124,8 +124,8 @@ export default function BookCatalog() { const [statusFilter, setStatusFilter] = useState(''); // Extract unique categories and languages for filter dropdowns - const categories = [...new Set(books.map(book => book.category))]; - const languages = [...new Set(books.map(book => book.language))]; + const categories = Array.from(new Set(books.map(book => book.category))); + const languages = Array.from(new Set(books.map(book => book.language))); // Apply filters when any filter changes useEffect(() => { diff --git a/pages/open-library/how-to-borrow.tsx b/pages/open-library/how-to-borrow.tsx index 451dfea..3304bdd 100644 --- a/pages/open-library/how-to-borrow.tsx +++ b/pages/open-library/how-to-borrow.tsx @@ -1,3 +1,4 @@ +import Link from 'next/link'; import React from 'react'; import { Button, Card, Col, Row } from 'react-bootstrap'; @@ -61,7 +62,10 @@ export default function HowToBorrowPage() { fCC 成都社区图书馆 {' '} 中查找自己感兴趣的书籍,或者在我们的{' '} - 书籍目录 中浏览。 + + 书籍目录 + {' '} + 中浏览。

@@ -214,9 +218,9 @@ export default function HowToBorrowPage() { > 填写书籍传递表 - - 浏览书籍目录 - + + 浏览书籍目录 +
@@ -274,14 +278,14 @@ export default function HowToBorrowPage() {

准备好借阅了吗?

- - 浏览书籍目录 - + + 浏览书籍目录 + 申请成为会员 From 99320ce1c351c3a0d180c03d122e1d268626f663 Mon Sep 17 00:00:00 2001 From: dethan3 Date: Thu, 19 Jun 2025 09:23:18 +0800 Subject: [PATCH 7/7] feat: Complete MVP layout improvements --- components/Layout/CardPage.tsx | 2 +- components/open-library/BookCard.tsx | 101 +++++ components/open-library/FeaturedBooks.tsx | 72 ++++ components/open-library/Footer.tsx | 108 +++-- components/open-library/HeroSection.tsx | 81 ++++ components/open-library/HowItWorks.tsx | 163 +++++++ components/open-library/Layout.tsx | 18 +- components/open-library/Navbar.tsx | 24 +- pages/api/core.ts | 2 +- pages/open-library/about.tsx | 201 --------- pages/open-library/book/[id].tsx | 5 +- pages/open-library/books/index.tsx | 274 +++--------- pages/open-library/donate.tsx | 254 ----------- pages/open-library/how-to-borrow.tsx | 2 +- pages/open-library/index.tsx | 496 +++++++++------------- pages/open-library/review.tsx | 372 ---------------- 16 files changed, 757 insertions(+), 1418 deletions(-) create mode 100644 components/open-library/BookCard.tsx create mode 100644 components/open-library/FeaturedBooks.tsx create mode 100644 components/open-library/HeroSection.tsx create mode 100644 components/open-library/HowItWorks.tsx delete mode 100644 pages/open-library/about.tsx delete mode 100644 pages/open-library/donate.tsx delete mode 100644 pages/open-library/review.tsx diff --git a/components/Layout/CardPage.tsx b/components/Layout/CardPage.tsx index 66ca2c6..f6da494 100644 --- a/components/Layout/CardPage.tsx +++ b/components/Layout/CardPage.tsx @@ -4,7 +4,7 @@ import { Col, Pagination, Row } from 'react-bootstrap'; import { SearchPageMeta } from '../../models/System'; export interface CardPageProps extends SearchPageMeta { - Card: ComponentClass | FC; + Card: ComponentClass> | FC>; cardLinkOf?: (id: string) => string; pageLinkOf: (page: number) => string; } diff --git a/components/open-library/BookCard.tsx b/components/open-library/BookCard.tsx new file mode 100644 index 0000000..9b607d6 --- /dev/null +++ b/components/open-library/BookCard.tsx @@ -0,0 +1,101 @@ +import Link from 'next/link'; +import React from 'react'; +import { Button, Card, Image } from 'react-bootstrap'; + +import { t } from '../../models/Translation'; + +export interface Book { + id: number; + title: string; + author: string; + cover?: string; + status?: 'available' | 'borrowed'; + category?: string; + description?: string; +} + +interface BookCardProps { + book: Book; + showStatus?: boolean; + variant?: 'featured' | 'catalog'; +} + +const BookCard: React.FC = ({ + book, + showStatus = false, + variant = 'featured', +}) => { + const cardClass = + variant === 'featured' + ? 'h-100 shadow-sm border-0' + : 'h-100 shadow border-0'; + + return ( + +
+ {showStatus && ( +
+ + {book.status === 'available' ? '可借阅' : '已借出'} + +
+ )} +
+ {`${book.title} +
+
+ + + {book.title} + + + {book.author} + + {book.category && ( + + + {book.category} + + )} +
+ + + +
+
+
+ ); +}; + +export default BookCard; diff --git a/components/open-library/FeaturedBooks.tsx b/components/open-library/FeaturedBooks.tsx new file mode 100644 index 0000000..b65c970 --- /dev/null +++ b/components/open-library/FeaturedBooks.tsx @@ -0,0 +1,72 @@ +import Link from 'next/link'; +import React from 'react'; +import { Button, Col, Row } from 'react-bootstrap'; + +import BookCard, { Book } from './BookCard'; +import { ContentContainer } from './Layout'; + +interface FeaturedBooksProps { + books: Book[]; + title?: string; + subtitle?: string; + showViewAll?: boolean; + viewAllLink?: string; + viewAllText?: string; +} + +const FeaturedBooks: React.FC = ({ + books, + title = '精选图书', + subtitle = '社区成员推荐的优质读物,涵盖技术、设计、创业等多个领域', + showViewAll = true, + viewAllLink = '/open-library/books', + viewAllText = '查看全部图书', +}) => { + return ( +
+ +
+

+ {title} +
+
+
+

+

+ {subtitle} +

+
+ + + {books.slice(0, 8).map(book => ( + + + + ))} + + + {showViewAll && ( +
+ + + +
+ )} +
+
+ ); +}; + +export default FeaturedBooks; diff --git a/components/open-library/Footer.tsx b/components/open-library/Footer.tsx index c17b219..7e3a39e 100644 --- a/components/open-library/Footer.tsx +++ b/components/open-library/Footer.tsx @@ -3,23 +3,11 @@ import { Col, Nav, Row } from 'react-bootstrap'; import { t } from '../../models/Translation'; -// +// 使用 Bootstrap 工具类替换内联样式的 ContentContainer const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ children, }) => { - return ( -
- {children} -
- ); + return
{children}
; }; const FooterComponent = () => { @@ -31,75 +19,83 @@ const FooterComponent = () => { }, []); return ( -
+
-
{t('open_library')}
-

{t('footer_description')}

-
- +
{t('open_library')}
+

+ {t('footer_description')} +

+
-
{t('quick_links_footer')}
+
{t('quick_links_footer')}
-
{t('contact')}
-

freeCodeCamp Chengdu Community

-

Chengdu, Sichuan, China

-

Email: contact@openlibrary.org

-

WeChat: FCCChengdu

+
{t('contact')}
+
+

+ + freeCodeCamp Chengdu Community +

+

+ + Chengdu, Sichuan, China +

+

+ + Email: contact@openlibrary.org +

+

+ + WeChat: FCCChengdu +

+
-
+
- {/* Use a more direct approach with inline styles to ensure visibility */} -
+
{isMounted ? ( <> © {new Date().getFullYear()} {t('open_library')}.{' '} diff --git a/components/open-library/HeroSection.tsx b/components/open-library/HeroSection.tsx new file mode 100644 index 0000000..3ecc17c --- /dev/null +++ b/components/open-library/HeroSection.tsx @@ -0,0 +1,81 @@ +import React from 'react'; +import { Button, Col, Image, Row } from 'react-bootstrap'; + +import { ContentContainer } from './Layout'; + +interface HeroSectionProps { + title?: string; + subtitle?: string; + ctaText?: string; + ctaLink?: string; + heroImage?: string; + heroImageAlt?: string; +} + +const HeroSection: React.FC = ({ + title = 'freeCodeCamp 成都社区 Open Library', + subtitle = '让知识在社区中自由流动,连接每一个热爱学习的心', + ctaText = '加入我们', + ctaLink = 'https://open-source-bazaar.feishu.cn/share/base/form/shrcngQgMrhjTh6ycO1zcaEWZld', + heroImage = '/images/open-library-hero.svg', + heroImageAlt = '社区成员分享书籍', +}) => { + return ( +
+ + + +
+

{title}

+

{subtitle}

+
+ + +
+
+ + +
+ {heroImageAlt} +
+ +
+
+
+ ); +}; + +export default HeroSection; diff --git a/components/open-library/HowItWorks.tsx b/components/open-library/HowItWorks.tsx new file mode 100644 index 0000000..ccc6b4c --- /dev/null +++ b/components/open-library/HowItWorks.tsx @@ -0,0 +1,163 @@ +import Link from 'next/link'; +import React from 'react'; +import { Button, Col, Row } from 'react-bootstrap'; + +import { ContentContainer } from './Layout'; + +interface Step { + id: number; + title: string; + description: string; + icon: string; + color: string; +} + +interface HowItWorksProps { + title?: string; + subtitle?: string; + steps?: Step[]; + showLearnMore?: boolean; + learnMoreLink?: string; +} + +const defaultSteps: Step[] = [ + { + id: 1, + title: '浏览图书', + description: '在图书目录中找到你感兴趣的书籍,查看详细信息和当前状态', + icon: 'bi-search', + color: '#6f42c1', + }, + { + id: 2, + title: '申请借阅', + description: '填写借阅申请表单,系统会自动联系当前持书人', + icon: 'bi-file-earmark-text', + color: '#0d6efd', + }, + { + id: 3, + title: '线下传递', + description: '与持书人约定传递方式,通常通过快递或面对面交接', + icon: 'bi-arrow-left-right', + color: '#fd7e14', + }, + { + id: 4, + title: '享受阅读', + description: '阅读完成后,可以写下书评并准备传递给下一位读者', + icon: 'bi-book-half', + color: '#198754', + }, +]; + +const HowItWorks: React.FC = ({ + title = '如何使用 Open Library', + subtitle = '简单四步,让知识在社区中自由流动', + steps = defaultSteps, + showLearnMore = true, + learnMoreLink = '/open-library/how-to-borrow', +}) => { + return ( +
+ +
+

+ {title} +
+
+
+

+

+ {subtitle} +

+
+ + + {steps.map((step, index) => ( + +
+
+
+ +
+ + {step.id} + + {/* 连接线仅在大屏幕显示且不是最后一个 */} + {index < steps.length - 1 && ( +
+
+
+ )} +
+

{step.title}

+

{step.description}

+
+ + ))} +
+ + {showLearnMore && ( +
+ + + +
+ )} +
+
+ ); +}; + +export default HowItWorks; diff --git a/components/open-library/Layout.tsx b/components/open-library/Layout.tsx index 92e09d5..c126f93 100644 --- a/components/open-library/Layout.tsx +++ b/components/open-library/Layout.tsx @@ -8,19 +8,7 @@ import { useOpenLibraryLayout } from './useOpenLibraryLayout'; const ContentContainer: React.FC<{ children: React.ReactNode }> = ({ children, }) => { - return ( -
- {children} -
- ); + return
{children}
; }; interface LayoutProps { @@ -49,7 +37,9 @@ const Layout: React.FC = ({ -
{children}
+
+ {children} +
diff --git a/components/open-library/Navbar.tsx b/components/open-library/Navbar.tsx index c870c9a..966c73a 100644 --- a/components/open-library/Navbar.tsx +++ b/components/open-library/Navbar.tsx @@ -18,21 +18,8 @@ const LibraryNavbar = () => { }, []); return ( - - {/* 使用自定义的居中容器替代 Container fluid,与页面内容保持一致的宽度和居中效果 */} -
+ +
{ - {/* 添加语言切换菜单 */} +
diff --git a/pages/api/core.ts b/pages/api/core.ts index 222dfb0..39db567 100644 --- a/pages/api/core.ts +++ b/pages/api/core.ts @@ -9,7 +9,7 @@ if (HTTP_PROXY) setGlobalDispatcher(new ProxyAgent(HTTP_PROXY)); export type NextAPI = ( req: NextApiRequest, res: NextApiResponse, -) => Promise; +) => Promise; export function safeAPI(handler: NextAPI): NextAPI { return async (req, res) => { diff --git a/pages/open-library/about.tsx b/pages/open-library/about.tsx deleted file mode 100644 index c8a8bf1..0000000 --- a/pages/open-library/about.tsx +++ /dev/null @@ -1,201 +0,0 @@ -import React from 'react'; -import { Card, Col, Container, Image, Row } from 'react-bootstrap'; - -import { ContentContainer, Layout } from '../../components/open-library/Layout'; - -export default function AboutPage() { - return ( - - -
-

关于社区图书馆

- - - -

我们的使命

-

- freeCodeCamp 成都社区「Open - Library」是一个开放、共享的社区图书馆,旨在促进知识交流,推动社区成员之间的学习和成长,增强社区成员之间的互动与信任。 -

-

- 我们深知知识的流动能够点燃创新的火花,因此,我们采用了一种独特的"无储存"借阅模式,让书籍在会员之间自由流转,而非集中存放。这种模式不仅节省了物理空间,更重要的是促进了社区成员之间的直接交流和互动。 -

-
-
- - - - - -

我们的价值观

-
    -
  • -
    -
    - -
    -
    -
    开放共享
    -

    - 我们相信知识应该是开放和共享的,每个人都有权利获取和贡献知识。 -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    社区驱动
    -

    - 我们的图书馆完全由社区成员驱动,每个人都可以贡献和受益。 -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    信任与责任
    -

    - 我们基于互相信任建立借阅系统,同时鼓励每个人对所借书籍负责。 -

    -
    -
    -
  • -
-
-
- - - - -

我们的特色

-
    -
  • -
    -
    - -
    -
    -
    "无储存"借阅模式
    -

    - 书籍在会员之间直接流转,无需集中存放,促进社区成员之间的直接交流。 -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    社区捐赠
    -

    - 所有书籍均来自社区成员的捐赠,体现了共享和互助的精神。 -

    -
    -
    -
  • -
  • -
    -
    - -
    -
    -
    线上管理
    -

    - 通过飞书多维表格进行书籍管理和借阅记录,方便透明。 -

    -
    -
    -
  • -
-
-
- -
- - - -

我们的团队

-

- Open Library 由 freeCodeCamp - 成都社区的志愿者团队运营。我们的团队成员来自各行各业,但都有一个共同的目标:促进知识共享和社区建设。 -

- - - - -
张伟
-

图书馆创始人

- - - -
李梅
-

社区协调员

- - - -
王晨
-

技术支持

- -
-
-
- - - -

加入我们

-

- 如果你热爱阅读,愿意分享知识,欢迎加入 freeCodeCamp - 成都社区「Open Library」,成为知识流动的一部分! -

-

成为会员后,你可以:

-
    -
  • 借阅其他会员捐赠的书籍
  • -
  • 捐赠自己的书籍给社区
  • -
  • 参与社区组织的读书会和讨论
  • -
  • 结识志同道合的朋友
  • -
- -
-
-
-
-
- ); -} diff --git a/pages/open-library/book/[id].tsx b/pages/open-library/book/[id].tsx index bf330a8..2dd8c62 100644 --- a/pages/open-library/book/[id].tsx +++ b/pages/open-library/book/[id].tsx @@ -1,3 +1,4 @@ +import Image from 'next/image'; import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; import { Badge, Button, Card, Col, Row, Tab, Tabs } from 'react-bootstrap'; @@ -263,11 +264,13 @@ export default function BookDetail() { - {book.title}
([ + const books: Book[] = [ { id: 1, title: 'Clean Code', @@ -48,18 +40,18 @@ export default function BookCatalog() { category: 'Programming', language: 'English', status: 'borrowed', - currentHolder: 'Zhang Wei', + currentHolder: 'John Doe', description: 'A modern introduction to programming', }, { id: 3, - title: 'Design Patterns', - author: 'Erich Gamma et al.', + title: 'The Pragmatic Programmer', + author: 'Andrew Hunt & David Thomas', cover: '/images/placeholder-book.svg', category: 'Programming', language: 'English', status: 'available', - description: 'Elements of Reusable Object-Oriented Software', + description: 'Your journey to mastery', }, { id: 4, @@ -68,13 +60,14 @@ export default function BookCatalog() { cover: '/images/placeholder-book.svg', category: 'Programming', language: 'English', - status: 'available', + status: 'borrowed', + currentHolder: 'Jane Smith', description: 'A book series on JavaScript', }, { id: 5, title: '深入理解计算机系统', - author: 'Randal E. Bryant', + author: "Randal E. Bryant & David R. O'Hallaron", cover: '/images/placeholder-book.svg', category: 'Computer Science', language: 'Chinese', @@ -115,203 +108,76 @@ export default function BookCatalog() { currentHolder: 'Wang Chen', description: 'CSS Secrets (Chinese Edition)', }, - ]); - - const [filteredBooks, setFilteredBooks] = useState(books); - const [searchTerm, setSearchTerm] = useState(''); - const [categoryFilter, setCategoryFilter] = useState(''); - const [languageFilter, setLanguageFilter] = useState(''); - const [statusFilter, setStatusFilter] = useState(''); - - // Extract unique categories and languages for filter dropdowns - const categories = Array.from(new Set(books.map(book => book.category))); - const languages = Array.from(new Set(books.map(book => book.language))); - - // Apply filters when any filter changes - useEffect(() => { - let results = books; - - // Apply search term filter - if (searchTerm) { - const term = searchTerm.toLowerCase(); - results = results.filter( - book => - book.title.toLowerCase().includes(term) || - book.author.toLowerCase().includes(term) || - (book.description && book.description.toLowerCase().includes(term)), - ); - } - - // Apply category filter - if (categoryFilter) { - results = results.filter(book => book.category === categoryFilter); - } - - // Apply language filter - if (languageFilter) { - results = results.filter(book => book.language === languageFilter); - } - - // Apply status filter - if (statusFilter) { - results = results.filter(book => book.status === statusFilter); - } - - setFilteredBooks(results); - }, [searchTerm, categoryFilter, languageFilter, statusFilter, books]); - - // Reset all filters - const resetFilters = () => { - setSearchTerm(''); - setCategoryFilter(''); - setLanguageFilter(''); - setStatusFilter(''); - }; + ]; return ( - + -

Book Catalog

- - {/* Search and Filters */} - - - - - - setSearchTerm(e.target.value)} - /> - - - - - - - setCategoryFilter(e.target.value)} - > - - {categories.map(category => ( - - ))} - - - - setLanguageFilter(e.target.value)} - > - - {languages.map(language => ( - - ))} - - - - setStatusFilter(e.target.value)} - > - - - - - - - - -
-
- - Showing {filteredBooks.length} of {books.length} books - -
- -
-
-
+
+
+

图书目录

+

+ 浏览我们的社区共享图书馆,发现有趣的书籍 +

+
- {/* Book Grid */} - - {filteredBooks.map(book => ( - - -
- -
- - {book.title} - - {book.author} - - - {book.description} - -
-
- - {book.category} - - - {book.language} - -
-
+ + {books.map(book => ( + + +
+ +
- {book.status === 'available' ? 'Available' : 'Borrowed'} + {book.status === 'available' ? '可借阅' : '已借出'} -
+ + + {book.title} + + + {book.author} + + + {book.category} • {book.language} + + {book.description && ( + + {book.description} + + )} + {book.status === 'borrowed' && book.currentHolder && ( + + 当前持书人: {book.currentHolder} + + )} +
+ - View Details - + 查看详情 +
- {book.status === 'borrowed' && ( -
- Currently with: {book.currentHolder} -
- )} -
- -
- - ))} -
- - {/* No Results */} - {filteredBooks.length === 0 && ( -
-

No books found

-

Try adjusting your search or filters

- -
- )} + + + + ))} + +
); diff --git a/pages/open-library/donate.tsx b/pages/open-library/donate.tsx deleted file mode 100644 index 7e54e0d..0000000 --- a/pages/open-library/donate.tsx +++ /dev/null @@ -1,254 +0,0 @@ -import React from 'react'; -import { Button, Card, Col, Row } from 'react-bootstrap'; - -import { ContentContainer, Layout } from '../../components/open-library/Layout'; - -export default function DonatePage() { - return ( - - -
-

书籍募捐

- - - -

为什么捐赠书籍?

-

- 您的一本书,可能会改变他人的一生。通过捐赠书籍,您不仅能够让闲置的知识重新流动,还能够帮助更多的人获取学习资源。 -

-

- 在 Open - Library,我们相信知识应该是流动的。您捐赠的每一本书都将在社区成员之间传递,让更多人受益。当您捐赠一本书,您不仅是在分享一个物品,更是在分享知识、经验和思想。 -

-
-
- - - - - -

捐赠流程

-
    -
  1. -
    -
    填写捐赠申请
    -

    - 填写我们的在线表单,提供您想要捐赠的书籍信息。 -

    -
    -
  2. -
  3. -
    -
    书籍登记
    -

    - 如所捐赠书籍在「fCC - 成都社区图书馆」还未登记,请先填写书籍登记表,然后回到第 - 1 步继续捐赠。建议在移动端设备上登记,方便扫描书籍 - ISBN 码。 -

    -
    -
  4. -
  5. -
    -
    书籍进入图书馆
    -

    - 完成以上流程后,书籍正式进入 Open Library - 的传递流程,开始流转于社区成员之间。 -

    -
    -
  6. -
- -
-
- - - - -

书籍登记

-

- 如果您要捐赠的书籍在我们的图书馆中还未登记,请先完成书籍登记流程。这有助于我们维护一个完整的书籍数据库,方便其他会员查找和借阅。 -

-

登记时,您需要提供以下信息:

-
    -
  • 书籍标题
  • -
  • 作者
  • -
  • ISBN(可通过扫描获取)
  • -
  • 出版社
  • -
  • 出版年份
  • -
  • 书籍类别
  • -
  • 书籍语言
  • -
  • 书籍简介
  • -
  • 书籍封面照片(可选)
  • -
- -
-
- -
- - - -

我们接受什么样的书籍?

- - -
✓ 我们欢迎
-
    -
  • 技术类书籍(编程、设计、数据科学等)
  • -
  • 科学类书籍
  • -
  • 商业和管理类书籍
  • -
  • 自我提升类书籍
  • -
  • 文学和小说
  • -
  • 状态良好的二手书
  • -
- - -
✗ 不适合捐赠
-
    -
  • 严重破损或缺页的书籍
  • -
  • 有大量笔记或标记的书籍
  • -
  • 过时的技术书籍(5年以上的技术书可能已过时)
  • -
  • 教科书和习题集
  • -
  • 杂志和期刊
  • -
- -
-
-
- - - - -
- - - -

常见问题

-
-
-

- -

-
-
- 您捐赠的书籍将进入我们的借阅系统,供社区成员借阅。当有人申请借阅时,书籍将从当前持有者(可能是您)直接传递给下一位借阅者。 -
-
-
-
-

- -

-
-
- 一旦书籍捐赠给图书馆,我们视为您已将书籍所有权转让给社区。如果您希望再次阅读这本书,可以通过正常的借阅流程申请借阅。 -
-
-
-
-

- -

-
-
- 您可以在我们的飞书多维表格中查看每本书的借阅记录,包括当前持有者和历史借阅情况。 -
-
-
-
-

- -

-
-
- 是的,我们要求捐赠者成为 Open Library - 的会员。这有助于我们建立一个基于信任的社区,并确保书籍的流转质量。 -
-
-
-
-
- -
-
- -
-

准备好捐赠书籍了吗?

- -
-
-
-
- ); -} diff --git a/pages/open-library/how-to-borrow.tsx b/pages/open-library/how-to-borrow.tsx index 3304bdd..1eb823a 100644 --- a/pages/open-library/how-to-borrow.tsx +++ b/pages/open-library/how-to-borrow.tsx @@ -1,6 +1,6 @@ import Link from 'next/link'; import React from 'react'; -import { Button, Card, Col, Row } from 'react-bootstrap'; +import { Card, Col, Row } from 'react-bootstrap'; import { ContentContainer, Layout } from '../../components/open-library/Layout'; diff --git a/pages/open-library/index.tsx b/pages/open-library/index.tsx index 5853be1..b25fd4a 100644 --- a/pages/open-library/index.tsx +++ b/pages/open-library/index.tsx @@ -1,321 +1,231 @@ +import Head from 'next/head'; import Link from 'next/link'; import React from 'react'; -import { Button, Card, Col, Form, Image, Row, Stack } from 'react-bootstrap'; +import { Card, Col, Row } from 'react-bootstrap'; -import { ContentContainer, Layout } from '../../components/open-library/Layout'; +import FeaturedBooks from '../../components/open-library/FeaturedBooks'; +import FooterComponent from '../../components/open-library/Footer'; +import HeroSection from '../../components/open-library/HeroSection'; +import HowItWorks from '../../components/open-library/HowItWorks'; +import { ContentContainer } from '../../components/open-library/Layout'; +import LibraryNavbar from '../../components/open-library/Navbar'; +import { useOpenLibraryLayout } from '../../components/open-library/useOpenLibraryLayout'; import { t } from '../../models/Translation'; -// TODO: Define a type for Book and Testimonial -type Book = { - id: number; - title: string; - author: string; - cover?: string; // Optional cover image URL -}; +// Sample data - these could be moved to a separate data file in the future +const featuredBooks = [ + { + id: 1, + title: 'Clean Code', + author: 'Robert C. Martin', + cover: '/images/placeholder-book.svg', + description: '编写优雅代码的艺术', + status: 'available' as const, + rating: 4.8, + tags: ['编程', '软件工程'], + }, + { + id: 2, + title: 'Eloquent JavaScript', + author: 'Marijn Haverbeke', + cover: '/images/placeholder-book.svg', + description: 'JavaScript 程序设计精粹', + status: 'borrowed' as const, + rating: 4.6, + tags: ['JavaScript', '前端'], + }, + { + id: 3, + title: 'Design Patterns', + author: 'Erich Gamma et al.', + cover: '/images/placeholder-book.svg', + description: '可复用面向对象软件的基础', + status: 'available' as const, + rating: 4.7, + tags: ['设计模式', '软件架构'], + }, + { + id: 4, + title: "You Don't Know JS", + author: 'Kyle Simpson', + cover: '/images/placeholder-book.svg', + description: 'JavaScript 深度解析系列', + status: 'available' as const, + rating: 4.5, + tags: ['JavaScript', '进阶'], + }, +]; -type Testimonial = { - id: number; - name: string; - quote: string; -}; +const workflowSteps = [ + { + id: 1, + icon: 'bi-search', + title: '浏览图书', + description: '在图书目录中寻找你感兴趣的书籍', + color: '#6f42c1', + }, + { + id: 2, + icon: 'bi-file-earmark-text', + title: '申请借阅', + description: '填写借阅申请表单,说明你的借阅意向', + color: '#0d6efd', + }, + { + id: 3, + icon: 'bi-people', + title: '联系持书人', + description: '我们会协助你联系当前的持书人安排交接', + color: '#fd7e14', + }, + { + id: 4, + icon: 'bi-book-half', + title: '传递分享', + description: '阅读完成后,将书籍传递给下一位读者', + color: '#198754', + }, +]; export default function OpenLibraryHomepage() { - // Sample featured books data - const featuredBooks: Book[] = [ - { - id: 1, - title: 'Clean Code', - author: 'Robert C. Martin', - cover: '/images/placeholder-book.svg', - }, // TODO: Replace placeholder path - { - id: 2, - title: 'Eloquent JavaScript', - author: 'Marijn Haverbeke', - cover: '/images/placeholder-book.svg', - }, - { - id: 3, - title: 'Design Patterns', - author: 'Erich Gamma et al.', - cover: '/images/placeholder-book.svg', - }, - { - id: 4, - title: "You Don't Know JS", - author: 'Kyle Simpson', - cover: '/images/placeholder-book.svg', - }, - ]; - - // Sample testimonials data - const testimonials: Testimonial[] = [ - { - id: 1, - name: 'Zhang Wei', - quote: - "Open Library helped me discover amazing tech books I couldn't find elsewhere.", - }, - { - id: 2, - name: 'Li Mei', - quote: - "The community is so supportive. I've both borrowed and donated books here.", - }, - { - id: 3, - name: 'Wang Chen', - quote: - 'As a student, this resource has been invaluable for my studies in computer science.', - }, - ]; + // Apply Open Library layout styles + useOpenLibraryLayout(); return ( - -
- {/* --- Hero Section --- */} -
- - - -

{t('hero_title')}

-

{t('hero_subtitle')}

- {/* TODO: Link this button to the actual Feishu form or member sign-up page */} - - - - {/* TODO: Replace placeholder */} - People sharing books - -
-
-
+ <> + + {`${t('open_library')} - freeCodeCamp 成都社区`} + + - {/* --- Featured Books Section --- */} -
- -

- {t('featured_books')} -

-

- {t('featured_books_subtitle')} -

- - {featuredBooks.map(book => ( - // TODO: Potentially move Card rendering to components/open-library/BookCard.tsx - - -
- {`${book.title} -
- - - {book.title} - - - {book.author} - -
- - - -
-
-
- - ))} -
-
- - - + + + + +
+ {/* About Section */} + +
+
+

+ 📚 关于我们 +

+

+ freeCodeCamp 成都社区「Open Library」开放共享图书馆 +

- -
- {/* --- Donation Callout Section --- */} -
- - - -

{t('share_your_knowledge')}

-

{t('donation_callout_subtitle')}

- - - + + + + +

🌟 我们的使命

+

+ 促进知识交流,推动社区成员之间的学习和成长,增强社区成员之间的互动与信任。 + 我们采用独特的"无储存"借阅模式,让书籍在会员之间自由流转。 +

+
+
- - {/* TODO: Replace placeholder */} - Book donation + + + +

💡 核心理念

+
    +
  • + ✦ 知识流动 - 书籍自由流转,促进知识传播 +
  • +
  • + ✦ 社区驱动 - 所有书籍来自成员捐赠 +
  • +
  • + ✦ 开放共享 - 促进交流和互动 +
  • +
+
+
-
-
+
+ - {/* --- How It Works Section --- */} -
+ {/* Featured Books Section */} +
-

{t('how_it_works')}

-

- {t('how_it_works_description')} -

- - -
- -
-

{t('step_1_find_book')}

-

{t('step_1_description')}

- - -
- -
-

{t('step_2_apply')}

-

{t('step_2_description')}

- - -
- -
-

{t('step_3_receive')}

-

{t('step_3_description')}

- -
-
- - - +
+

+ 📖 精选图书 +

+

发现社区成员推荐的优质图书

+ -
+
+ + + + - {/* --- Testimonials Section --- */} -
+ {/* Simple Donation Section */} +
-

- {t('community_voices')} -

-

- {t('community_voices_description')} -

- - {testimonials.map(testimonial => ( - - - -
-

"{testimonial.quote}"

-
- {testimonial.name} -
-
-
-
- - ))} -
-
- - - + + GitHub Sponsors + + + + + 分享你的图书 + + +
-
- - {/* --- Newsletter Section --- */} -
- - - - - -

{t('stay_updated')}

-

- {t('newsletter_description')} -

- {/* TODO: Implement actual newsletter subscription logic */} -
e.preventDefault()}> - {' '} - {/* Prevent default form submission */} - - - - -
-
-
- -
-
-
+
-
+ + + ); } diff --git a/pages/open-library/review.tsx b/pages/open-library/review.tsx deleted file mode 100644 index 28222cf..0000000 --- a/pages/open-library/review.tsx +++ /dev/null @@ -1,372 +0,0 @@ -import React, { useState } from 'react'; -import { Button, Card, Col, Form, Row, Tab, Tabs } from 'react-bootstrap'; - -import { ContentContainer, Layout } from '../../components/open-library/Layout'; - -// Review type definition -type Review = { - id: number; - bookTitle: string; - bookAuthor: string; - bookCover?: string; - reviewer: string; - rating: number; - comment: string; - date: string; -}; - -export default function ReviewPage() { - // Sample reviews data - in a real app, this would come from an API - const [reviews, setReviews] = useState([ - { - id: 1, - bookTitle: 'Clean Code', - bookAuthor: 'Robert C. Martin', - bookCover: '/images/placeholder-book.svg', - reviewer: 'Wang Chen', - rating: 5, - comment: - 'This book completely changed how I approach writing code. Highly recommended for all developers!', - date: '2023-11-25', - }, - { - id: 2, - bookTitle: 'Clean Code', - bookAuthor: 'Robert C. Martin', - bookCover: '/images/placeholder-book.svg', - reviewer: 'Li Mei', - rating: 4, - comment: - 'Great principles that have stood the test of time. Some examples are a bit dated but the concepts are solid.', - date: '2023-09-10', - }, - { - id: 3, - bookTitle: 'Eloquent JavaScript', - bookAuthor: 'Marijn Haverbeke', - bookCover: '/images/placeholder-book.svg', - reviewer: 'Liu Jie', - rating: 5, - comment: - 'Perfect for beginners and intermediate JavaScript developers. The exercises are particularly helpful.', - date: '2023-12-05', - }, - { - id: 4, - bookTitle: 'Design Patterns', - bookAuthor: 'Erich Gamma et al.', - bookCover: '/images/placeholder-book.svg', - reviewer: 'Chen Ming', - rating: 4, - comment: - 'A classic that has stood the test of time. The examples are in C++ and Smalltalk, but the concepts apply to any OO language.', - date: '2023-07-25', - }, - { - id: 5, - bookTitle: '深入理解计算机系统', - bookAuthor: 'Randal E. Bryant', - bookCover: '/images/placeholder-book.svg', - reviewer: 'Zhang Wei', - rating: 5, - comment: - '这是一本非常全面的计算机系统书籍,对理解计算机底层工作原理非常有帮助。', - date: '2023-10-15', - }, - ]); - - // Function to render star rating - const renderStars = (rating: number) => { - return ( -
- {[...Array(5)].map((_, i) => ( - - {i < rating ? '\u2605' : '\u2606'} - - ))} -
- ); - }; - - return ( - - -
-

书籍评价

- - - -

社区书评

-

- 阅读是一种体验,分享让这种体验更加丰富。浏览社区成员的书评,或者分享您自己的阅读感受。 -

-
- -
-
-
- - - -
- {reviews.map(review => ( - - - - -
- {review.bookTitle} -
{review.bookTitle}
-

- {review.bookAuthor} -

-
- - -
-
{review.reviewer}
- {renderStars(review.rating)} -
-

{review.comment}

-
- - {new Date(review.date).toLocaleDateString( - 'en-US', - { - year: 'numeric', - month: '2-digit', - day: '2-digit', - }, - )} - - -
- -
-
-
- ))} -
-
- -
- {reviews - .sort( - (a, b) => - new Date(b.date).getTime() - new Date(a.date).getTime(), - ) - .slice(0, 3) - .map(review => ( - - - - -
- {review.bookTitle} -
- {review.bookTitle} -
-

- {review.bookAuthor} -

-
- - -
-
{review.reviewer}
- {renderStars(review.rating)} -
-

{review.comment}

-
- - {new Date(review.date).toLocaleDateString( - 'en-US', - { - year: 'numeric', - month: '2-digit', - day: '2-digit', - }, - )} - - -
- -
-
-
- ))} -
-
- -
- {reviews - .filter(review => review.rating >= 5) - .map(review => ( - - - - -
- {review.bookTitle} -
- {review.bookTitle} -
-

- {review.bookAuthor} -

-
- - -
-
{review.reviewer}
- {renderStars(review.rating)} -
-

{review.comment}

-
- - {new Date(review.date).toLocaleDateString( - 'en-US', - { - year: 'numeric', - month: '2-digit', - day: '2-digit', - }, - )} - - -
- -
-
-
- ))} -
-
-
- - - -

写下您的书评

-

- 阅读完一本书后,请花几分钟时间分享您的阅读体验。您的评价将帮助其他社区成员找到适合他们的书籍。 -

-
- -
-
-
- - - -

书评指南

- - -
如何写一篇有帮助的书评
-
    -
  • 简要概述书籍内容,但不要透露关键情节
  • -
  • 分享您从书中获得的主要收获
  • -
  • 提及书籍的优点和可能的缺点
  • -
  • 说明适合阅读这本书的人群
  • -
  • 分享书中让您印象深刻的观点或引用
  • -
- - -
评分参考
-
    -
  • -
    -
    ★★★★★
    -
    杰出,强烈推荐,改变思维的书籍
    -
    -
  • -
  • -
    -
    ★★★★☆
    -
    非常好,值得推荐,有一些小缺点
    -
    -
  • -
  • -
    -
    ★★★☆☆
    -
    好,有价值,但不突出
    -
    -
  • -
  • -
    -
    ★★☆☆☆
    -
    一般,有一些有用信息,但整体平淡
    -
    -
  • -
  • -
    -
    ★☆☆☆☆
    -
    不推荐,内容质量较低或不准确
    -
    -
  • -
- -
-
-
-
-
-
- ); -}