Skip to content

Commit e1f9323

Browse files
committed
feat: show page last modified date
1 parent 70cf804 commit e1f9323

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

content/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ nav {
4343
overscroll-behavior: none;
4444
}
4545

46+
#last-modified {
47+
font-size: 0.75em;
48+
text-align: center;
49+
}
50+
#last-modified a {
51+
display: inline;
52+
}
53+
4654
/* Push the nav links block to the bottom of the nav when
4755
there is extra vertical space. */
4856
#nav-links {

generate.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import csv
55
import re
6+
import subprocess
67
import markdown
78

89
SUMMARY_MAX = 200
@@ -86,6 +87,16 @@ def generate_nav(page, sections):
8687
<a href="https://discord.com/invite/hRwE4Zr" target="_blank" class="fa-brands fa-discord"></a>
8788
</div>
8889
"""
90+
modified = subprocess.run(["git", "log", "-1", "--format=%ct", "--", os.path.join("content", page)], capture_output=True, text=True).stdout.strip()
91+
if modified:
92+
commit = subprocess.run(["git", "log", "-1", "--format=%H", "--", os.path.join("content", page)], capture_output=True, text=True).stdout.strip()
93+
out += f"""
94+
<div id='last-modified'>
95+
This page was last modified <a href="https://github.com/p2sr/rules/commit/{commit}" target="_blank">
96+
<time data-epoch=\"{modified}\" class=\"discord-timestamp\" data-format=\"R\"></time>
97+
</a>
98+
</div>
99+
"""
89100

90101
return out
91102

0 commit comments

Comments
 (0)