Skip to content

Commit 778d46a

Browse files
committed
restore anchors
1 parent 6c57ea3 commit 778d46a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/djot.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ export function render(doc: Doc, ctx: RenderCtx): HtmlString {
5656
`;
5757
} else {
5858
const tag = `h${node.level}`;
59+
const id = node.level > 1 && section?.autoAttributes?.id;
5960
const children = r.renderChildren(node);
60-
return `\n<${tag}${r.renderAttributes(node)}>${children}</${tag}>\n`;
61+
const children_anchored = id
62+
? `<a href="#${id}">${children}</a>`
63+
: `${children}`;
64+
return `\n<${tag}${r.renderAttributes(node)}>${children_anchored}</${tag}>\n`;
6165
}
6266
},
6367
ordered_list: (node: OrderedList, r: HTMLRenderer): string => {

src/templates.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,8 @@ export function BlogRoll({ posts }: { posts: FeedEntryData[] }) {
183183

184184
const list_items = posts.map((post) => (
185185
<li>
186-
<h2>
187-
<span class="meta">
188-
<Time date={post.date} />, {domain(post.url)}
189-
</span>
190-
<a href={post.url}>{post.title}</a>
191-
</h2>
186+
<span class="meta"> <Time date={post.date} />, {domain(post.url)}</span>
187+
<h2><a href={post.url}>{post.title}</a></h2>
192188
</li>
193189
));
194190

0 commit comments

Comments
 (0)