From d691de5fdf5270b52ad1f38f263c014a456f8320 Mon Sep 17 00:00:00 2001 From: novalagung Date: Fri, 15 Nov 2024 19:41:38 +0700 Subject: [PATCH] refactor: content --- .github/workflows/deploy.yml | 15 +++++---------- {etc => content}/book.json | 9 +++++++++ {etc => content}/cover.jpg | Bin {etc => content}/cover_small.jpg | Bin {etc => content}/cover_square.png | Bin {etc => content}/robots.txt | 0 {etc => content}/script-gitbook-plugin-disqus.js | 0 .../style-website.css | 2 +- etc/main.go | 7 ------- 9 files changed, 15 insertions(+), 18 deletions(-) rename {etc => content}/book.json (86%) rename {etc => content}/cover.jpg (100%) rename {etc => content}/cover_small.jpg (100%) rename {etc => content}/cover_square.png (100%) rename {etc => content}/robots.txt (100%) rename {etc => content}/script-gitbook-plugin-disqus.js (100%) rename etc/style-custom.css => content/style-website.css (99%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3b929641..c5c44caac 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,13 +21,8 @@ jobs: run: | rm -f README.md mv content/* . - mv etc/cover_small.jpg . - mv etc/cover_square.png . - mv etc/cover.jpg . - mv etc/style-custom.css . + mv book.json etc/ mv etc/main.go . - mv etc/robots.txt . - mv etc/script-gitbook-plugin-disqus.js . npm install -g gitbook-cli gitbook install cd ~/.gitbook/versions/3.2.3 && npm i npm@5 @@ -73,12 +68,12 @@ jobs: run: | rm -f README.md mv content/* . - mv etc/cover_small.jpg . - mv etc/cover_square.png . - mv etc/cover.jpg . mv etc/main.go . - go run main.go -mode=ebook -adjustment=pre + rm -f book.json gitbook install + cd ~/.gitbook/versions/3.2.3 && npm i npm@5 + cd ${{ github.workspace }} + go run main.go -mode=ebook -adjustment=pre mkdir _book/ - name: 'Generating ebook in pdf' run: gitbook pdf ./ ./_book/dasarpemrogramangolang.pdf diff --git a/etc/book.json b/content/book.json similarity index 86% rename from etc/book.json rename to content/book.json index dfc2a902a..e19acef6c 100644 --- a/etc/book.json +++ b/content/book.json @@ -7,6 +7,15 @@ "meta", "sitemap" ], + "styles": { + "website": "style-website.css" + }, + "pdf": { + "margin": { + "left": 10, + "right": 10 + } + }, "pluginsConfig": { "disqus": { "shortName": "dasarpemrogramangolang" diff --git a/etc/cover.jpg b/content/cover.jpg similarity index 100% rename from etc/cover.jpg rename to content/cover.jpg diff --git a/etc/cover_small.jpg b/content/cover_small.jpg similarity index 100% rename from etc/cover_small.jpg rename to content/cover_small.jpg diff --git a/etc/cover_square.png b/content/cover_square.png similarity index 100% rename from etc/cover_square.png rename to content/cover_square.png diff --git a/etc/robots.txt b/content/robots.txt similarity index 100% rename from etc/robots.txt rename to content/robots.txt diff --git a/etc/script-gitbook-plugin-disqus.js b/content/script-gitbook-plugin-disqus.js similarity index 100% rename from etc/script-gitbook-plugin-disqus.js rename to content/script-gitbook-plugin-disqus.js diff --git a/etc/style-custom.css b/content/style-website.css similarity index 99% rename from etc/style-custom.css rename to content/style-website.css index 16a5bb455..8d7765510 100644 --- a/etc/style-custom.css +++ b/content/style-website.css @@ -32,7 +32,7 @@ body .book.font-family-1, .book-summary { } .page-inner { - max-width: fit-content; + max-width: none; padding: 20px 100px 40px 100px; } diff --git a/etc/main.go b/etc/main.go index 7198e1662..ba73a6d74 100644 --- a/etc/main.go +++ b/etc/main.go @@ -178,13 +178,6 @@ func webbookPostAdjustment() { ` + buttonToFind htmlString = strings.ReplaceAll(htmlString, buttonToFind, buttonReplacement) - // ==== inject adjustment css - adjustmentCSSBuf, _ := os.ReadFile("./style-custom.css") - os.WriteFile("./_book/gitbook/style-custom.css", adjustmentCSSBuf, 0644) - adjustmentCSSToFind := `` - adjustmentCSSReplacement := `` + adjustmentCSSToFind - htmlString = strings.ReplaceAll(htmlString, adjustmentCSSToFind, adjustmentCSSReplacement) - // ==== inject github stars js script buttonScriptToFind := `` buttonScriptReplacement := `` + buttonScriptToFind