Skip to content

Commit c56125f

Browse files
authored
fix scroll-margin (#346)
1 parent 27f46c3 commit c56125f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/site-kit/src/lib/components/Text.svelte

+8-2
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@
7575
h2,
7676
h3 {
7777
max-width: 100%;
78-
text-overflow: ellipsis;
79-
overflow: hidden;
8078
padding: 0 1em 0 0;
8179
8280
@media (min-width: 768px) {
8381
margin: 0 0 0 -2em;
8482
padding: 0 1em 0 2em;
8583
}
84+
85+
/* we can't use `text-overflow` on the heading itself,
86+
because `overflow: hidden` defeats `scroll-margin` */
87+
& > span {
88+
display: block;
89+
overflow: hidden;
90+
text-overflow: ellipsis;
91+
}
8692
}
8793
8894
h2 {

packages/site-kit/src/lib/markdown/renderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ export async function render_content_markdown(
269269
headings[depth - 1] = slugify(raw);
270270
headings.length = depth;
271271
const slug = headings.filter(Boolean).join('-');
272-
return `<h${depth} id="${slug}">${text.replace(
272+
return `<h${depth} id="${slug}"><span>${text.replace(
273273
/<\/?code>/g,
274274
''
275-
)}<a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${depth}>`;
275+
)}</span><a href="#${slug}" class="permalink"><span class="visually-hidden">permalink</span></a></h${depth}>`;
276276
},
277277
code({ text }) {
278278
return snippets.get(text);

0 commit comments

Comments
 (0)