這是一個基於 Next.js 的講道文翻譯網站,用於將上傳的 .docx 格式講道文件轉換為網頁格式,方便瀏覽和翻譯。
- 支援上傳 .docx 格式的講道文件
- 自動將文件轉換為 Markdown 格式
- 支援大型文件的分割處理
- 可擴展的架構,支援未來添加更多文件格式
本專案使用模組化設計,主要架構如下:
- 核心功能:提供擴展性強的文件處理機制
- 工廠模式:根據文件類型選擇適當的處理器
- 處理器:
DocxProcessor: 處理 Word 文檔格式GenericProcessor: 作為其他格式的基類
- 工具類:
split-markdown.ts: 分割大型 Markdown 文件storage.ts: 提供 Vercel KV 儲存功能
convert-document.ts: 處理檔案上傳和轉換的 Server Action- 從原有的
convert.ts重構,採用更模組化的方法
page.tsx: 主頁,提供檔案上傳表單articles/[slug]/page.tsx: 顯示轉換後的文章頁面
Article.tsx: 文章容器元件MarkdownContent.tsx: Markdown 渲染元件
首先,運行開發服務器:
npm run dev
# 或
yarn dev
# 或
pnpm dev在瀏覽器中打開 http://localhost:3000 即可看到結果。
- Next.js - React 框架
- Vercel KV - 鍵值存儲
- Mammoth.js - Word 文檔轉換
- React Markdown - Markdown 渲染
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.