Skip to content

Commit 803bd5c

Browse files
jfarcandclaude
andcommitted
feat: add dynamic version footer to all documentation pages
- Add custom CSS/JS for version footer bar - Footer displays: Pierre version, commit hash (linked), build date - Supports light/dark themes with appropriate styling - Update GitHub Actions to: - Checkout pierre_mcp_server to extract version from Cargo.toml - Generate version.json with version, commit, and date info - Daily scheduled rebuilds to keep docs current - Footer positioned fixed at bottom, content padded to avoid overlap Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 0cd7f45 commit 803bd5c

File tree

4 files changed

+192
-2
lines changed

4 files changed

+192
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# ABOUTME: GitHub Actions workflow for deploying mdBook to GitHub Pages
2-
# ABOUTME: Builds the book on every push to main and deploys to Pages
2+
# ABOUTME: Builds the book with version info from pierre_mcp_server and deploys to Pages
33

44
name: Deploy mdBook to GitHub Pages
55

66
on:
77
push:
88
branches: ["main"]
99
workflow_dispatch:
10+
# Rebuild daily to keep "Updated" date fresh if pierre_mcp_server changes
11+
schedule:
12+
- cron: '0 6 * * *' # 6 AM UTC daily
1013

1114
permissions:
1215
contents: read
@@ -21,9 +24,55 @@ jobs:
2124
build:
2225
runs-on: ubuntu-latest
2326
steps:
24-
- name: Checkout
27+
- name: Checkout tutorial
2528
uses: actions/checkout@v4
2629

30+
- name: Checkout pierre_mcp_server for version info
31+
uses: actions/checkout@v4
32+
with:
33+
repository: Async-IO/pierre_mcp_server
34+
path: pierre_mcp_server
35+
fetch-depth: 1
36+
37+
- name: Extract version information
38+
id: version
39+
run: |
40+
# Extract version from Cargo.toml
41+
PIERRE_VERSION=$(grep '^version = ' pierre_mcp_server/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
42+
43+
# Get commit info from pierre_mcp_server
44+
cd pierre_mcp_server
45+
COMMIT_HASH=$(git rev-parse HEAD)
46+
COMMIT_SHORT=$(git rev-parse --short HEAD)
47+
cd ..
48+
49+
# Build date
50+
BUILD_DATE=$(date -u +"%Y-%m-%d")
51+
52+
# Export for later steps
53+
echo "pierre_version=$PIERRE_VERSION" >> $GITHUB_OUTPUT
54+
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
55+
echo "commit_short=$COMMIT_SHORT" >> $GITHUB_OUTPUT
56+
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
57+
58+
echo "📦 Pierre version: $PIERRE_VERSION"
59+
echo "🔗 Commit: $COMMIT_SHORT ($COMMIT_HASH)"
60+
echo "📅 Build date: $BUILD_DATE"
61+
62+
- name: Generate version.json
63+
run: |
64+
cat > version.json << EOF
65+
{
66+
"pierre_version": "${{ steps.version.outputs.pierre_version }}",
67+
"commit_hash": "${{ steps.version.outputs.commit_hash }}",
68+
"commit_short": "${{ steps.version.outputs.commit_short }}",
69+
"build_date": "${{ steps.version.outputs.build_date }}",
70+
"repo_url": "https://github.com/Async-IO/pierre_mcp_server"
71+
}
72+
EOF
73+
echo "Generated version.json:"
74+
cat version.json
75+
2776
- name: Setup mdBook
2877
uses: peaceiris/actions-mdbook@v2
2978
with:
@@ -32,6 +81,9 @@ jobs:
3281
- name: Build the book
3382
run: mdbook build
3483

84+
- name: Copy version.json to build output
85+
run: cp version.json book/version.json
86+
3587
- name: Setup Pages
3688
uses: actions/configure-pages@v5
3789

book.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ preferred-dark-theme = "ayu"
1515
git-repository-url = "https://github.com/Async-IO/pierre-tutorial"
1616
edit-url-template = "https://github.com/Async-IO/pierre-tutorial/edit/main/{path}"
1717
site-url = "/pierre-tutorial/"
18+
additional-css = ["theme/version-footer.css"]
19+
additional-js = ["theme/version-footer.js"]
1820

1921
[output.html.print]
2022
enable = true

theme/version-footer.css

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* ABOUTME: Custom footer styles for version information */
2+
/* ABOUTME: Displays Pierre version, commit hash, and build date */
3+
4+
.version-footer {
5+
position: fixed;
6+
bottom: 0;
7+
left: 0;
8+
right: 0;
9+
height: 32px;
10+
background: linear-gradient(90deg, #1a1a2e 0%, #16213e 100%);
11+
border-top: 1px solid #0f3460;
12+
display: flex;
13+
align-items: center;
14+
justify-content: center;
15+
gap: 24px;
16+
font-size: 12px;
17+
color: #a0a0a0;
18+
z-index: 1000;
19+
padding: 0 16px;
20+
}
21+
22+
.version-footer a {
23+
color: #7c3aed;
24+
text-decoration: none;
25+
transition: color 0.2s;
26+
}
27+
28+
.version-footer a:hover {
29+
color: #a78bfa;
30+
}
31+
32+
.version-footer .separator {
33+
color: #404040;
34+
}
35+
36+
.version-footer .version-badge {
37+
background: rgba(124, 58, 237, 0.15);
38+
color: #a78bfa;
39+
padding: 2px 8px;
40+
border-radius: 4px;
41+
font-family: monospace;
42+
}
43+
44+
.version-footer .commit-hash {
45+
font-family: monospace;
46+
color: #6b7280;
47+
}
48+
49+
/* Adjust main content to account for footer */
50+
.content {
51+
padding-bottom: 48px !important;
52+
}
53+
54+
/* Dark theme adjustments */
55+
.ayu .version-footer,
56+
.coal .version-footer,
57+
.navy .version-footer {
58+
background: linear-gradient(90deg, #0d1117 0%, #161b22 100%);
59+
border-top-color: #30363d;
60+
}
61+
62+
/* Light theme adjustments */
63+
.light .version-footer,
64+
.rust .version-footer {
65+
background: linear-gradient(90deg, #f6f8fa 0%, #ffffff 100%);
66+
border-top-color: #d0d7de;
67+
color: #57606a;
68+
}
69+
70+
.light .version-footer .version-badge,
71+
.rust .version-footer .version-badge {
72+
background: rgba(124, 58, 237, 0.1);
73+
color: #7c3aed;
74+
}

theme/version-footer.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// ABOUTME: Injects version footer into mdBook pages
2+
// ABOUTME: Reads version info from generated version.json file
3+
4+
(function() {
5+
'use strict';
6+
7+
// Default values (will be overwritten by version.json if available)
8+
let versionInfo = {
9+
pierre_version: 'dev',
10+
commit_hash: 'unknown',
11+
commit_short: 'unknown',
12+
build_date: new Date().toISOString().split('T')[0],
13+
repo_url: 'https://github.com/Async-IO/pierre_mcp_server'
14+
};
15+
16+
// Try to load version info from generated file
17+
fetch('./version.json')
18+
.then(response => response.json())
19+
.then(data => {
20+
versionInfo = { ...versionInfo, ...data };
21+
renderFooter();
22+
})
23+
.catch(() => {
24+
// If version.json doesn't exist (local dev), use defaults
25+
renderFooter();
26+
});
27+
28+
function renderFooter() {
29+
// Don't add footer if already exists
30+
if (document.querySelector('.version-footer')) return;
31+
32+
const footer = document.createElement('div');
33+
footer.className = 'version-footer';
34+
footer.innerHTML = `
35+
<span>
36+
<strong>Pierre</strong>
37+
<span class="version-badge">v${escapeHtml(versionInfo.pierre_version)}</span>
38+
</span>
39+
<span class="separator">|</span>
40+
<span>
41+
Built from
42+
<a href="${escapeHtml(versionInfo.repo_url)}/commit/${escapeHtml(versionInfo.commit_hash)}"
43+
target="_blank"
44+
rel="noopener noreferrer"
45+
class="commit-hash"
46+
title="View commit on GitHub">
47+
${escapeHtml(versionInfo.commit_short)}
48+
</a>
49+
</span>
50+
<span class="separator">|</span>
51+
<span>Updated: ${escapeHtml(versionInfo.build_date)}</span>
52+
`;
53+
54+
document.body.appendChild(footer);
55+
}
56+
57+
function escapeHtml(text) {
58+
const div = document.createElement('div');
59+
div.textContent = text;
60+
return div.innerHTML;
61+
}
62+
})();

0 commit comments

Comments
 (0)