Skip to content

Commit d15fdc1

Browse files
Merge pull request #3 from mathspp/codex/update-html-structure-in-index.html
Update index layout to use shared styles
2 parents 78736c1 + d139d23 commit d15fdc1

1 file changed

Lines changed: 52 additions & 54 deletions

File tree

build_index.py

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def _select_recent(
9696
def _render_recent_section(recently_added: Sequence[dict], recently_updated: Sequence[dict]) -> str:
9797
def render_list(tools: Sequence[dict]) -> str:
9898
if not tools:
99-
return "<li>No entries available.</li>"
99+
return " <li class=\"recent-empty\">No entries available.</li>"
100100
items = []
101101
for tool in tools:
102102
slug = tool.get("slug", "")
@@ -107,7 +107,7 @@ def render_list(tools: Sequence[dict]) -> str:
107107
formatted_date = _format_display_date(parsed_date)
108108
else:
109109
formatted_date = ""
110-
110+
111111
# Create colophon link for the date
112112
colophon_url = f"https://tools.mathspp.com/colophon#{filename}" if filename else "#"
113113
date_html = (
@@ -116,25 +116,27 @@ def render_list(tools: Sequence[dict]) -> str:
116116
else ""
117117
)
118118
items.append(
119-
f'<li><a href="{url}">{slug}</a>{date_html}</li>'
119+
f" <li><a href=\"{url}\">{slug}</a>{date_html}</li>"
120120
)
121121
return "\n".join(items)
122122

123123
section_html = f"""
124-
<div class="recent-container">
125-
<div class="recent-column">
126-
<h2>Recently added</h2>
127-
<ul class="recent-list">
128-
{render_list(recently_added)}
129-
</ul>
130-
</div>
131-
<div class="recent-column">
132-
<h2>Recently updated</h2>
133-
<ul class="recent-list">
134-
{render_list(recently_updated)}
135-
</ul>
124+
<section class="surface recent-highlights">
125+
<div class="recent-grid">
126+
<article class="recent-card">
127+
<h2>Recently added</h2>
128+
<ul class="recent-list">
129+
{render_list(recently_added)}
130+
</ul>
131+
</article>
132+
<article class="recent-card">
133+
<h2>Recently updated</h2>
134+
<ul class="recent-list">
135+
{render_list(recently_updated)}
136+
</ul>
137+
</article>
136138
</div>
137-
</div>
139+
</section>
138140
"""
139141
return section_html
140142

@@ -179,63 +181,59 @@ def build_index() -> None:
179181
<meta charset="UTF-8">
180182
<meta name="viewport" content="width=device-width, initial-scale=1.0">
181183
<title>tools.mathspp.com</title>
184+
<link rel="stylesheet" href="styles.css">
182185
<style>
183186
body {{
184-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
185-
line-height: 1.6;
186-
max-width: 980px;
187-
margin: 0 auto;
188-
padding: 20px;
189-
color: #24292e;
190-
}}
191-
h1 {{
192-
border-bottom: 1px solid #eaecef;
193-
padding-bottom: 0.3em;
194-
}}
195-
h2 {{
196-
border-bottom: 1px solid #eaecef;
197-
padding-bottom: 0.3em;
198-
margin-top: 24px;
199-
}}
200-
a {{
201-
color: #0366d6;
202-
text-decoration: none;
203-
}}
204-
a:hover {{
205-
text-decoration: underline;
187+
margin: 0;
188+
padding: 0;
206189
}}
207-
code {{
208-
background-color: rgba(27,31,35,0.05);
209-
border-radius: 3px;
210-
padding: 0.2em 0.4em;
190+
main.page-shell {{
191+
max-width: 960px;
192+
margin: 0 auto;
193+
padding: 32px 20px 56px;
194+
display: grid;
195+
gap: 2rem;
211196
}}
212-
.recent-container {{
213-
display: flex;
214-
gap: 24px;
215-
flex-wrap: wrap;
216-
margin-bottom: 24px;
197+
.recent-highlights {{
198+
padding: clamp(1.5rem, 3vw, 2.25rem);
217199
}}
218-
.recent-column {{
219-
flex: 1 1 300px;
200+
.recent-grid {{
201+
display: grid;
202+
gap: 1.5rem;
203+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
220204
}}
221-
.recent-column h2 {{
222-
margin-top: 0;
205+
.recent-card {{
206+
display: grid;
207+
gap: 0.75rem;
223208
}}
224209
.recent-list {{
225210
list-style: none;
226211
margin: 0;
227212
padding: 0;
213+
display: grid;
214+
gap: 0.6rem;
228215
}}
229-
.recent-list li {{
230-
margin-bottom: 0.5em;
216+
.recent-list a {{
217+
font-weight: 600;
231218
}}
232219
.recent-date {{
233-
color: #6a737d;
220+
font-size: 0.9rem;
221+
color: var(--tx-2);
222+
}}
223+
.recent-empty {{
224+
color: var(--tx-2);
225+
}}
226+
@media (max-width: 720px) {{
227+
main.page-shell {{
228+
padding: 24px 16px 40px;
229+
}}
234230
}}
235231
</style>
236232
</head>
237233
<body>
234+
<main class="page-shell">
238235
{body_html}
236+
</main>
239237
</body>
240238
</html>
241239
"""

0 commit comments

Comments
 (0)