Skip to content

Commit ea3bd12

Browse files
committed
don't nest date into h1
1 parent 97310d9 commit ea3bd12

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

content/css/main.css

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ body {
1515
margin-right: auto;
1616
}
1717

18-
header { margin-bottom: 2rem; }
19-
header > nav { display: flex; column-gap: 2ch; align-items: baseline; flex-wrap: wrap; }
20-
header a { font-style: normal; color: rgba(0, 0, 0, .8); text-decoration: none; }
21-
header a:hover { color: rgba(0, 0, 0, .8); text-decoration: underline; }
22-
header .title { font-size: 1.2em; flex-grow: 2; }
18+
header { /* Site Header */
19+
margin-bottom: 2rem;
20+
& nav { display: flex; column-gap: 2ch; align-items: baseline; flex-wrap: wrap; }
21+
& a { font-style: normal; color: rgba(0, 0, 0, .8); text-decoration: none; }
22+
& a:hover { color: rgba(0, 0, 0, .8); text-decoration: underline; }
23+
& .title { font-size: 1.2em; flex-grow: 2; }
24+
}
25+
26+
header:has(> h1) { /* Article Header */
27+
margin-bottom: 0.75rem;
28+
& h1 { margin-bottom: 0; line-height: 1.2 }
29+
}
2330

24-
footer { margin-top: 2rem; }
25-
footer > p { display: flex; column-gap: 2ch; justify-content: center; flex-wrap: wrap; }
26-
footer a { color: rgba(0, 0, 0, .8); text-decoration: none; white-space: nowrap; }
27-
footer i { vertical-align: middle; color: rgba(0, 0, 0, .8) }
31+
footer {
32+
margin-top: 2rem;
33+
& p { display: flex; column-gap: 2ch; justify-content: center; flex-wrap: wrap; }
34+
& a { color: rgba(0, 0, 0, .8); text-decoration: none; white-space: nowrap; }
35+
& i { vertical-align: middle; color: rgba(0, 0, 0, .8) }
36+
}
2837

2938
article > *, article > section > *, figure.blockquote { max-width: 55ch; }
3039
article > section, article > figure, article > section > figure { max-width: 80ch; }
@@ -166,7 +175,7 @@ kbd > kbd {
166175

167176
dfn, .small-caps { font-style: normal; font-variant: small-caps; }
168177

169-
.meta { display: block; display: block; color: #828282; font-family: "Open Sans", sans-serif; font-size: 1.5rem;}
178+
.meta { display: block; color: #828282; font-family: "Open Sans", sans-serif; font-size: 1.5rem;}
170179

171180
.menu { font-weight: bold; }
172181

src/djot.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,20 @@ export function render(doc: Doc, ctx: RenderCtx): HtmlString {
4444
return result;
4545
},
4646
heading: (node: Heading, r: HTMLRenderer) => {
47-
const tag = `h${node.level}`;
48-
const date = node.level == 1 && ctx.date
49-
? time_html(ctx.date, "meta")
50-
: "";
51-
const children = r.renderChildren(node);
5247
if (node.level == 1) ctx.title = get_string_content(node);
53-
const id = node.level > 1 && section?.autoAttributes?.id;
54-
if (id) {
48+
if (node.level == 1 && ctx.date) {
49+
const date = time_html(ctx.date, "meta");
50+
const children = r.renderChildren(node);
5551
return `
56-
<${tag}${r.renderAttributes(node)}>
57-
<a href="#${id}">${children} ${date}</a>
58-
</${tag}>\n`;
52+
<header>
53+
<h1${r.renderAttributes(node)}>${children}</h1>
54+
${date}
55+
</header>
56+
`;
5957
} else {
60-
return `\n<${tag}${
61-
r.renderAttributes(node)
62-
}>${children} ${date}</${tag}>\n`;
58+
const tag = `h${node.level}`;
59+
const children = r.renderChildren(node);
60+
return `\n<${tag}${r.renderAttributes(node)}>${children}</${tag}>\n`;
6361
}
6462
},
6563
ordered_list: (node: OrderedList, r: HTMLRenderer): string => {

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ async function build(params: {
167167
for (const page of pages) {
168168
const text = await Deno.readTextFile(`content/${page}.dj`);
169169
const ast = await djot.parse(text);
170-
const html = djot.render(ast, {});
170+
const html = djot.render(ast, {
171+
date: page == "resume" ? new Date("May 21, 2024") : undefined,
172+
});
171173
await update_file(
172174
`out/www/${page}.html`,
173175
html_ugly(Page(page, html)),

src/templates.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ export function Page(name: string, content: HtmlString) {
147147
export function PostList({ posts }: { posts: PostData[] }) {
148148
const list_items = posts.map((post) => (
149149
<li>
150-
<h2>
151-
<Time className="meta" date={post.date} />
152-
<a href={post.path}>{post.title}</a>
153-
</h2>
150+
<Time className="meta" date={post.date} />
151+
<h2><a href={post.path}>{post.title}</a></h2>
154152
</li>
155153
));
156154

0 commit comments

Comments
 (0)