// @ts-checkimport { defineConfig } from'astro/config';
import mdx from'@astrojs/mdx';
import sitemap from'@astrojs/sitemap';
/** * DÆMONBins deploys to Vercel at the domain root — no base path — so every * internal link resolves from `/`. `src/lib/url.ts`'s `url()` helper stays the * single chokepoint for internal links (with an empty base it is a passthrough * that just guarantees a leading slash), which keeps the components portable if * the site is ever moved back under a sub-path. * * `site` is used for the sitemap, canonical URLs and Open Graph tags. Set it to * the site's real production origin — the Vercel custom domain (or the default * `*.vercel.app` URL) once known. */const SITE ='https://lotl.daemon-sec.xyz';
/** * The drop cap, matching the cheatsheet/main site: the opening letter of a * prose block floated three lines deep in EB Garamond, split into a real * `<span class="cap">` so it stays selectable and searchable. */const CAP_MIN_CHARS =80;
function rehypeDropCap() {
/** @param {any} node hast node */function textLength(node) {
if (node.type ==='text') return node.value.trim().length;
if (!node.children) return0;
return node.children.reduce((/** @type {number} */ n, /** @type {any} */ c) => n + textLength(c), 0);
}
/** * @param {any} node hast node * @returns {any} the first non-blank hast text node, or null */function firstText(node) {
if (!node.children) returnnull;
for (const child of node.children) {
if (child.type ==='text'&& child.value.trim()) return child;
if (child.type ==='element') {
/** @type {any} */const found = firstText(child);
if (found) return found;
}
}
returnnull;
}
return (/** @type {any} */ tree) => {
const paragraph = tree.children.find(
(/** @type {any} */ n) => n.type ==='element'&& n.tagName ==='p'&& textLength(n) >= CAP_MIN_CHARS,
);
if (!paragraph) return;
const lead = firstText(paragraph);
if (!lead) return;
const trimmed = lead.value.trimStart();
const letter = trimmed[0];
if (!letter ||!/[A-Za-z0-9]/.test(letter)) return;
lead.value = trimmed.slice(1);
paragraph.children.unshift({
type:'element',
tagName:'span',
properties: { className: ['cap'] },
children: [{ type:'text', value: letter }],
});
};
}
exportdefault defineConfig({
site: SITE,
// 'never' + the default directory output: URLs (sitemap, Astro.url, canonical)// carry no trailing slash — matching vercel.json's `trailingSlash: false` so// no canonical ever points at a 308 — while files still land as// …/index.html, which keeps Pagefind's result hrefs clean. trailingSlash:'never',
integrations: [mdx(), sitemap()],
markdown: {
rehypePlugins: [rehypeDropCap],
shikiConfig: {
// Code blocks are dark plates in both modes (see prose.css), so there// is no light listing to flip to — but the *palette* does change them.// Rosé Pine Moon is inlined; Gruvbox's colours ride along as// --shiki-gruvbox and prose.css switches to them under// <html data-palette="gruvbox">. Gruvepine keeps Rosé Pine's syntax,// which is the point of it. themes: { rosepine:'rose-pine-moon', gruvbox:'gruvbox-dark-hard' },
defaultColor:'rosepine',
wrap:false,
},
},
});