Skip to content

Commit

Permalink
refactor: code structure & design
Browse files Browse the repository at this point in the history
  • Loading branch information
novalagung committed Nov 19, 2024
1 parent bd528cc commit a41e3c2
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 41 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion content/2-instalasi-golang.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A.2. Instalasi Golang (Stable & Unstable)
# A.2. Instalasi Golang

Hal pertama yang perlu dilakukan sebelum bisa menggunakan Go adalah meng-*install*-nya terlebih dahulu. Panduan instalasi sebenarnya sudah disediakan di situs resmi Go [http://golang.org/doc/install#install](http://golang.org/doc/install#install).

Expand Down
2 changes: 1 addition & 1 deletion content/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

* A. Pemrograman Go Dasar
* [A.1. Belajar Golang](1-berkenalan-dengan-golang.md)
* [A.2. Instalasi Golang (Stable & Unstable)](2-instalasi-golang.md)
* [A.2. Instalasi Golang](2-instalasi-golang.md)
* [A.3. Setup Go Modules](A-setup-go-project-dengan-go-modules.md)
* [A.4. Setup GOPATH dan Workspace](A-gopath-dan-workspace.md)
* [A.5. Instalasi Editor](A-instalasi-editor.md)
Expand Down
9 changes: 9 additions & 0 deletions etc/book.json → content/book.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"meta",
"sitemap"
],
"styles": {
"website": "style-website.css?v=2"
},
"pdf": {
"margin": {
"left": 10,
"right": 10
}
},
"pluginsConfig": {
"disqus": {
"shortName": "dasarpemrogramangolang"
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
83 changes: 61 additions & 22 deletions etc/style-custom.css → content/style-website.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,10 @@ body .book.font-family-1, .book-summary {
}

.page-inner {
max-width: fit-content;
max-width: none;
padding: 20px 100px 40px 100px;
}

/* disable word wrap at left sidebar */
.book-summary ul.summary li a, .book-summary ul.summary li span {
text-overflow: initial;
white-space: normal;
line-height: 1.4em;
padding: 9px 15px;
}

/* sidebar background */
.book-summary {
background-color: #ffffff;
}

/* sidebar ads animation */
/* .book-summary .summary > li:nth-child(8) a {
color: white;
Expand Down Expand Up @@ -81,18 +68,64 @@ body .book.font-family-1, .book-summary {
background: hsla(0,0%,53%,.1);
}

/* sidebar active link */
.book-summary li.active>a:before {
content: " ";
/* sidebar background */
.book-summary {
background-color: #ffffff;
}

/* sidebar items */
.book-summary ul.summary li a, .book-summary ul.summary li span {
text-overflow: initial;
white-space: normal;
line-height: 1.4em;
padding: 9px 10px 9px 6px;
}
.book-summary ul.summary li.chapter {
position: relative;
padding-left: 10px;
padding-right: 10px;
}
.book-summary ul.summary > li.chapter:before {
position: absolute;
right: 0;
top: 0;
bottom: 0;
content: " ";
background-color: #F4F4F5;
width: 2px;
background-color: #008cff;
left: 27px;
top: 39px;
bottom: 0px;
}
.book-summary li.active>a {
.book-summary ul.summary li.chapter span {
font-weight: 600;
}
.book-summary ul.summary li.chapter a {
text-indent: -41px;
padding-left: 51px;
}
.book-summary ul.summary li.chapter a:hover, .book-summary ul.summary li.chapter.active a {
background-color: #F4F4F5;
font-weight: bold;
border-radius: 6px;
text-decoration: none;
}
.book-summary ul.summary li span:before {
content: "📄";
margin-right: 2px;
font-size: 1.2em;
}
.book-summary ul.summary li.divider {
margin: 18px 0 7px;
}

/* docsearch */
#book-doc-search-input {
padding: 5px;
}
#book-doc-search-input .DocSearch-Button {
border-radius: 6px;
background-color: #F4F4F5;
}
#book-doc-search-input .DocSearch-Button:hover {
box-shadow: inset 0 0 0 2px #008cff;
}

/* make the sidebar wider, and adjust the content to match it */
Expand Down Expand Up @@ -220,6 +253,12 @@ ins.adsbygoogle {
}
}

/* content */
.markdown-section h1 {
font-size: 3em;
font-weight: 400;
margin-bottom: 0.4em;
}
.markdown-section hr,
.ebook-wrapper hr {
height: 1px !important;
Expand Down
7 changes: 0 additions & 7 deletions etc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,6 @@ func webbookPostAdjustment() {
</div>` + 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 := `</head>`
adjustmentCSSReplacement := `<link rel="stylesheet" href="gitbook/style-custom.css?v=` + getVersion() + `">` + adjustmentCSSToFind
htmlString = strings.ReplaceAll(htmlString, adjustmentCSSToFind, adjustmentCSSReplacement)

// ==== inject github stars js script
buttonScriptToFind := `</head>`
buttonScriptReplacement := `<script async defer src="https://buttons.github.io/buttons.js"></script>` + buttonScriptToFind
Expand Down

0 comments on commit a41e3c2

Please sign in to comment.