Skip to content

Commit 3fbdfe9

Browse files
committed
Add localized generation date at the bottom of doc pages
1 parent 42d579a commit 3fbdfe9

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

scripts/patch-mdbook-theme.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,30 @@ document.addEventListener('DOMContentLoaded', function() {
160160
links.appendChild(langDiv);
161161
162162
additional.appendChild(links);
163+
164+
// Generation date (localized) — append at the bottom of <main>
165+
var main = document.querySelector('#mdbook-content main');
166+
if (main) {
167+
var genDate = document.createElement('div');
168+
genDate.style.fontSize = '0.75em';
169+
genDate.style.color = 'var(--fg)';
170+
genDate.style.opacity = '0.6';
171+
genDate.style.marginTop = '2em';
172+
genDate.style.textAlign = 'right';
173+
var locale = currentLang.replace('_', '-');
174+
var dateStr = new Date(GENDATE_PLACEHOLDER).toLocaleDateString(locale, {
175+
year: 'numeric', month: 'long', day: 'numeric'
176+
});
177+
genDate.textContent = dateStr;
178+
main.appendChild(genDate);
179+
}
163180
});
164181
</script>
165182
ENDSCRIPT
166183

167-
# Inject the dynamically-built language list
184+
# Inject the dynamically-built language list and generation date
185+
GENDATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
168186
sed -i "s|LANGS_PLACEHOLDER|[${LANGS_JSON}]|" "$HEAD_HBS"
187+
sed -i "s|GENDATE_PLACEHOLDER|'${GENDATE}'|" "$HEAD_HBS"
169188

170189
echo "Patched $HEAD_HBS with language selector and utility links"

0 commit comments

Comments
 (0)