more
All checks were successful
Deploy to Pages / build (pull_request) Successful in 1m36s

This commit is contained in:
Andras Schmelczer 2026-05-25 12:52:37 +01:00
parent 84769f9ce4
commit fd4bb61b5f
30 changed files with 355 additions and 156 deletions

View file

@ -40,16 +40,11 @@ const postLastmodLookup = new Map(
export default defineConfig({
site: 'https://schmelczer.dev',
trailingSlash: 'ignore',
build: { inlineStylesheets: 'always' },
redirects: {
'/writing/': '/articles/',
'/writing/[slug]': '/articles/[slug]',
},
integrations: [
sitemap({
filter: (page) => {
const path = new URL(page).pathname;
return !path.startsWith('/writing/') && path !== '/404/';
return !/^\/tags\/[^/]+\/?$/.test(path) && path !== '/404/';
},
serialize(item) {
const url = new URL(item.url);
@ -93,7 +88,6 @@ export default defineConfig({
behavior: 'append',
properties: {
className: ['heading-anchor'],
ariaLabel: 'Permalink',
},
// Glyph rendered via CSS ::before so it doesn't leak into the TOC
// when astro:content extracts heading.text from the rendered HTML.
@ -110,11 +104,33 @@ export default defineConfig({
return (tree) => {
visit(tree, 'element', (node) => {
if (!SCROLLABLE.has(node.tagName)) return;
node.properties = node.properties ?? {};
node.properties.tabindex = '0';
});
};
},
function rehypeLabelHeadingPermalinks() {
function textOf(node) {
if (!node) return '';
if (node.type === 'text') return node.value ?? '';
return (node.children ?? []).map(textOf).join('');
}
return (tree) => {
visit(tree, 'element', (node) => {
if (!/^h[2-6]$/.test(node.tagName)) return;
const headingText = textOf(node).trim();
if (!headingText) return;
for (const child of node.children ?? []) {
const className = child.properties?.className;
const classes = Array.isArray(className) ? className : [className];
if (child.tagName === 'a' && classes.includes('heading-anchor')) {
child.properties.ariaLabel = `Permalink to ${headingText}`;
}
}
});
};
},
],
},
});