Skip to content

Commit 8699f11

Browse files
committed
Initial commit
0 parents  commit 8699f11

39 files changed

+4340
-0
lines changed

Diff for: .github/workflows/deploy-mdbook.yml

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: Deploy mdBook Site to Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
permissions:
13+
contents: read
14+
id-token: write
15+
pages: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build-deps:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cargo/bin
32+
~/.cargo/git
33+
~/.cargo/registry
34+
target
35+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-deps
36+
37+
- name: Check for existing binaries
38+
id: check-binaries
39+
run: |
40+
if [ -f ~/.cargo/bin/mdbook ] && \
41+
[ -f ~/.cargo/bin/mdbook-admonish ] && \
42+
[ -f ~/.cargo/bin/mdbook-footnote ] && \
43+
[ -f ~/.cargo/bin/mdbook-graphviz ] && \
44+
[ -f ~/.cargo/bin/mdbook-mermaid ]; then
45+
echo "exists=true" >> $GITHUB_OUTPUT
46+
echo "All mdbook binaries found, will skip build"
47+
else
48+
echo "exists=false" >> $GITHUB_OUTPUT
49+
echo "Some mdbook binaries missing, will build"
50+
fi
51+
52+
- name: Build all mdbook components
53+
if: steps.check-binaries.outputs.exists != 'true'
54+
run: |
55+
mkdir -p target
56+
cargo install mdbook --target-dir target
57+
cargo install mdbook-admonish --target-dir target
58+
cargo install mdbook-footnote --target-dir target
59+
cargo install mdbook-graphviz --target-dir target
60+
cargo install mdbook-mermaid --target-dir target
61+
62+
- name: Upload Binaries
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: mdbook-binaries
66+
path: |
67+
~/.cargo/bin/mdbook
68+
~/.cargo/bin/mdbook-admonish
69+
~/.cargo/bin/mdbook-footnote
70+
~/.cargo/bin/mdbook-graphviz
71+
~/.cargo/bin/mdbook-mermaid
72+
retention-days: 1
73+
74+
deploy-mdbook:
75+
needs: build-deps
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Checkout Source
79+
uses: actions/checkout@v4
80+
81+
- name: Install System Dependencies
82+
env:
83+
DEBIAN_FRONTEND: noninteractive
84+
run: |
85+
sudo apt-get update
86+
sudo apt-get install -y --no-install-recommends graphviz
87+
88+
- name: Download mdbook binaries
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: mdbook-binaries
92+
path: /usr/local/bin
93+
94+
- name: Make binaries executable
95+
run: |
96+
sudo chmod +x /usr/local/bin/mdbook
97+
sudo chmod +x /usr/local/bin/mdbook-admonish
98+
sudo chmod +x /usr/local/bin/mdbook-footnote
99+
sudo chmod +x /usr/local/bin/mdbook-graphviz
100+
sudo chmod +x /usr/local/bin/mdbook-mermaid
101+
102+
- name: Prepare Assets Directories
103+
run: mkdir -p src/fonts src/assets theme
104+
105+
- name: Setup Catppuccin Theme
106+
run: |
107+
# Create theme directory
108+
mkdir -p theme
109+
110+
# Download latest Catppuccin theme
111+
curl -sSfL -o theme/catppuccin.css \
112+
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin.css
113+
114+
# Download Catppuccin admonish theme
115+
curl -sSfL -o theme/catppuccin-admonish.css \
116+
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin-admonish.css
117+
118+
# Download default theme's index.hbs for customization
119+
curl -sSfL -o theme/index.hbs \
120+
https://raw.githubusercontent.com/rust-lang/mdBook/master/src/theme/index.hbs
121+
122+
# Update index.hbs theme options
123+
sed -i 's/Light/Latte/; s/Rust/Frappé/; s/Coal/Macchiato/; s/Navy/Mocha/; /Ayu/d' theme/index.hbs
124+
125+
- name: Download Additional Assets
126+
run: |
127+
# Devicon Fonts and CSS
128+
curl -sSf \
129+
-o devicon.min.css \
130+
https://raw.githubusercontent.com/devicons/devicon/master/devicon.min.css
131+
curl -sSf \
132+
-o src/fonts/devicon.eot \
133+
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.eot
134+
curl -sSf \
135+
-o src/fonts/devicon.svg \
136+
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.svg
137+
curl -sSf \
138+
-o src/fonts/devicon.ttf \
139+
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.ttf
140+
curl -sSf \
141+
-o src/fonts/devicon.woff \
142+
https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.woff
143+
144+
# WhichLang Assets
145+
curl -sSf \
146+
-o src/assets/whichlang.css \
147+
https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/src/whichlang.css
148+
curl -sSf \
149+
-o src/assets/whichlang.js \
150+
https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/dist/whichlang.js
151+
152+
- name: Build the mdBook Site
153+
run: mdbook build
154+
155+
- name: Turn off Jekyll
156+
run: touch book/.nojekyll
157+
158+
- name: Upload Artifact
159+
uses: actions/upload-pages-artifact@v3
160+
with:
161+
path: ./book
162+
163+
- name: Deploy to GitHub Pages
164+
id: deployment
165+
uses: actions/deploy-pages@v4
166+
if: ${{ github.ref == 'refs/heads/main' }}

Diff for: .github/workflows/lint-markdown.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Lint Markdown Files
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
paths:
8+
- "**.md"
9+
workflow_dispatch:
10+
11+
jobs:
12+
lint-markdown:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Source
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "20"
22+
23+
- name: Install markdownlint-cli
24+
run: npm install -g markdownlint-cli
25+
26+
- name: Create markdownlint config
27+
run: |
28+
cat > .markdownlint.json << 'EOF'
29+
{
30+
"default": true,
31+
"MD013": {
32+
"code_blocks": false,
33+
"headings": false,
34+
"line_length": 100,
35+
"strict": false,
36+
"tables": false
37+
},
38+
"MD033": {
39+
"allowed_elements": ["br"]
40+
}
41+
}
42+
EOF
43+
44+
- name: Run markdownlint
45+
id: lint
46+
continue-on-error: true
47+
run: |
48+
# Run markdownlint and capture output
49+
OUTPUT=$(markdownlint '**/*.md' --ignore node_modules 2>&1)
50+
EXIT_CODE=$?
51+
52+
# Create a summary
53+
{
54+
echo "## Markdown Lint Results"
55+
echo
56+
if [ $EXIT_CODE -eq 0 ]; then
57+
echo "✅ All markdown files pass linting"
58+
else
59+
echo "❌ Found linting issues"
60+
echo
61+
echo "### Issues by File"
62+
echo
63+
echo "\`\`\`"
64+
# Process the output to group by file
65+
echo "$OUTPUT" | awk -F':' '
66+
{
67+
file=$1
68+
if (!files[file]) {
69+
files[file] = 1
70+
print "\n" file ":"
71+
}
72+
sub(/^[^:]*:[^:]*:/, " Line " $2 ":")
73+
print
74+
}'
75+
echo "\`\`\`"
76+
fi
77+
} >> $GITHUB_STEP_SUMMARY
78+
79+
exit $EXIT_CODE

Diff for: .vscode/settings.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"markdown.extension.toc.levels": "3..6",
3+
"markdownlint.config": {
4+
"MD010": {
5+
"spaces_per_tab": 3
6+
},
7+
"MD013": {
8+
"code_blocks": false,
9+
"headings": false,
10+
"line_length": 100,
11+
"strict": false,
12+
"tables": false
13+
},
14+
"MD033": {
15+
"allowed_elements": ["br"]
16+
},
17+
"no-hard-tabs": true
18+
}
19+
}

Diff for: Dockerfile

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
FROM alpine:latest
2+
3+
# Install runtime dependencies
4+
RUN apk add --no-cache curl graphviz
5+
6+
# Set up environment variables
7+
ENV MDBOOK_VERSION="0.4.37"
8+
ENV MDBOOK_ADMONISH_VERSION="1.15.0"
9+
ENV MDBOOK_FOOTNOTE_VERSION="0.1.3"
10+
ENV MDBOOK_GRAPHVIZ_VERSION="0.1.6"
11+
ENV MDBOOK_MERMAID_VERSION="0.13.0"
12+
13+
# Download and install mdBook and plugins
14+
RUN cd /tmp && \
15+
# Install mdBook
16+
curl -sSL \
17+
"https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
18+
| tar -xz && \
19+
mv mdbook /usr/local/bin/ && \
20+
# Install mdbook-admonish
21+
curl -sSL \
22+
"https://github.com/tommilligan/mdbook-admonish/releases/download/v${MDBOOK_ADMONISH_VERSION}/mdbook-admonish-v${MDBOOK_ADMONISH_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
23+
| tar -xz && \
24+
mv mdbook-admonish /usr/local/bin/ && \
25+
# Install mdbook-footnote
26+
curl -sSL \
27+
"https://github.com/daviddrysdale/mdbook-footnote/releases/download/v${MDBOOK_FOOTNOTE_VERSION}/mdbook-footnote-v${MDBOOK_FOOTNOTE_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
28+
| tar -xz && \
29+
mv mdbook-footnote /usr/local/bin/ && \
30+
# Install mdbook-graphviz
31+
curl -sSL \
32+
"https://github.com/dylanowen/mdbook-graphviz/releases/download/v${MDBOOK_GRAPHVIZ_VERSION}/mdbook-graphviz-v${MDBOOK_GRAPHVIZ_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
33+
| tar -xz && \
34+
mv mdbook-graphviz /usr/local/bin/ && \
35+
# Install mdbook-mermaid
36+
curl -sSL \
37+
"https://github.com/badboy/mdbook-mermaid/releases/download/v${MDBOOK_MERMAID_VERSION}/mdbook-mermaid-v${MDBOOK_MERMAID_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
38+
| tar -xz && \
39+
mv mdbook-mermaid /usr/local/bin/
40+
41+
# Set up theme directory and download Catppuccin theme
42+
WORKDIR /workdir
43+
RUN mkdir -p /workdir/theme && \
44+
curl -sSf \
45+
-o /workdir/theme/catppuccin.css \
46+
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin.css && \
47+
curl -sSf \
48+
-o /workdir/theme/catppuccin-admonish.css \
49+
https://github.com/catppuccin/mdBook/releases/latest/download/catppuccin-admonish.css && \
50+
curl -sSf \
51+
-o /workdir/theme/index.hbs \
52+
https://raw.githubusercontent.com/catppuccin/mdBook/refs/heads/main/example/theme/index.hbs
53+
54+
# Create a non-root user
55+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
56+
USER appuser
57+
58+
# Set the entrypoint
59+
ENTRYPOINT ["mdbook"]
60+
CMD ["build"]

0 commit comments

Comments
 (0)