Skip to content

Commit

Permalink
feat: 支持 EPUB 与 PDF 版
Browse files Browse the repository at this point in the history
  • Loading branch information
Zh40Le1ZOOB committed Mar 11, 2024
1 parent 126704e commit 11c7720
Show file tree
Hide file tree
Showing 10 changed files with 969 additions and 67 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
paths:
- ".github/**"
- "src/**"
- "theme/**"
- "book.toml"
- "package-lock.json"
- "package.json"

Expand Down Expand Up @@ -32,10 +34,52 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: current
- name: Build
- name: Install node packages
run: npm ci
- name: Install mdBook
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook
git: https://github.com/rust-lang/mdBook
- name: Install mdbook-epub
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-epub
git: https://github.com/Michael-F-Bryan/mdbook-epub
- name: Install mdbook-typst-pdf
uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-typst-pdf
git: https://github.com/KaiserY/mdbook-typst-pdf
- name: Install fonts
run: |
npm i
npm run docs:build
mkdir -p ~/.local/share/fonts/
curl -sL -o Noto_Sans.zip https://fonts.google.com/download?family=Noto%20Sans
unzip Noto_Sans.zip -d ~/.local/share/fonts/Noto_Sans
curl -sL -o Noto_Sans_SC.zip https://fonts.google.com/download?family=Noto%20Sans%20SC
unzip Noto_Sans_SC.zip -d ~/.local/share/fonts/Noto_Sans_SC
curl -sL -o Noto_Sans_Mono.zip https://fonts.google.com/download?family=Noto%20Sans%20Mono
unzip Noto_Sans_Mono.zip -d ~/.local/share/fonts/Noto_Sans_Mono
rm -fv ~/.local/share/fonts/Noto_Sans_Mono/NotoSansMono-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Sans_KR.zip https://fonts.google.com/download?family=Noto%20Sans%20KR
unzip Noto_Sans_KR.zip -d ~/.local/share/fonts/Noto_Sans_KR
curl -sL -o Noto_Sans_Thai.zip https://fonts.google.com/download?family=Noto%20Sans%20Thai
unzip Noto_Sans_Thai.zip -d ~/.local/share/fonts/Noto_Sans_Thai
rm -fv ~/.local/share/fonts/Noto_Sans_Thai/NotoSansThai-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Sans_Arabic.zip https://fonts.google.com/download?family=Noto%20Sans%20Arabic
unzip Noto_Sans_Arabic.zip -d ~/.local/share/fonts/Noto_Sans_Arabic
curl -sL -o Noto_Sans_Hebrew.zip https://fonts.google.com/download?family=Noto%20Sans%20Hebrew
unzip Noto_Sans_Hebrew.zip -d ~/.local/share/fonts/Noto_Sans_Hebrew
curl -sL -o Noto_Sans_Devanagari.zip https://fonts.google.com/download?family=Noto%20Sans%20Devanagari
unzip Noto_Sans_Devanagari.zip -d ~/.local/share/fonts/Noto_Sans_Devanagari
rm -fv ~/.local/share/fonts/Noto_Sans_Devanagari/NotoSansDevanagari-VariableFont_wdth,wght.ttf
curl -sL -o Noto_Emoji.zip https://fonts.google.com/download?family=Noto%20Emoji
unzip Noto_Emoji.zip -d ~/.local/share/fonts/Noto_Emoji
curl -sL -o times_sans_serif.zip https://dl.dafont.com/dl/?f=times_sans_serif
unzip times_sans_serif.zip -d ~/.local/share/fonts/times_sans_serif
fc-cache -rv
- name: Build
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
book
src/.vitepress/cache
src/.vitepress/dist
node_modules
18 changes: 18 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[book]
title = "药娘的天空"
authors = ["乱世银娘"]
description = "《药娘的天空》精修版"
language = "zh-CN"

[build]
create-missing = false

[output.epub]
additional-css = ["theme/indent.css"]
cover-image = "illustrations/cover.jpg"
no-section-label = true

[output.typst-pdf]
pdf = true
custom-template = "theme/template.typ"
section-number = false
126 changes: 63 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"docs:dev": "vitepress dev src",
"docs:build": "vitepress build src",
"docs:preview": "vitepress preview src"
"docs:preview": "vitepress preview src",
"build": "npm run docs:build && mdbook build && cp book/epub/*.epub src/.vitepress/dist/ && cp book/typst-pdf/*.pdf src/.vitepress/dist/"
}
}
2 changes: 2 additions & 0 deletions src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default defineConfig({
],
lang: "zh-CN",
cleanUrls: true,
srcExclude: ["**/SUMMARY.md"],
lastUpdated: true,
sitemap: {
hostname: "https://proskynova.github.io",
Expand All @@ -35,6 +36,7 @@ export default defineConfig({
useFolderTitleFromIndexFile: true,
useFolderLinkFromIndexFile: true,
collapsed: true,
excludeFiles: ["SUMMARY.md"],
}),
socialLinks: [{ icon: "github", link: "https://github.com/proskynova" }],
footer: {
Expand Down
Loading

0 comments on commit 11c7720

Please sign in to comment.