51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// astro.config.mjs
|
|
// @ts-check
|
|
import { defineConfig } from "astro/config";
|
|
import mdx from "@astrojs/mdx";
|
|
import sitemap from "@astrojs/sitemap";
|
|
|
|
import rehypeSlug from "rehype-slug";
|
|
import rehypeAutolinkHeadings from "rehype-autolink-headings";
|
|
|
|
import rehypeDetailsSections from "./scripts/rehype-details-sections.mjs";
|
|
import rehypeParagraphIds from "./src/plugins/rehype-paragraph-ids.js";
|
|
|
|
const must = (name, fn) => {
|
|
if (typeof fn !== "function") {
|
|
throw new Error(`[astro.config] rehype plugin "${name}" is not a function (export default vs named?)`);
|
|
}
|
|
return fn;
|
|
};
|
|
|
|
export default defineConfig({
|
|
output: "static",
|
|
trailingSlash: "always",
|
|
|
|
site: process.env.PUBLIC_SITE ?? "http://localhost:4321",
|
|
|
|
integrations: [
|
|
mdx(),
|
|
sitemap({
|
|
filter: (page) => !page.includes("/api/") && !page.endsWith("/robots.txt"),
|
|
}),
|
|
],
|
|
|
|
// ✅ Plugins appliqués AU MDX
|
|
mdx: {
|
|
// ✅ MDX hérite déjà de markdown.rehypePlugins
|
|
// donc ici on ne met QUE le spécifique MDX
|
|
rehypePlugins: [
|
|
must("rehype-details-sections", rehypeDetailsSections),
|
|
],
|
|
},
|
|
|
|
// ✅ Plugins appliqués au Markdown non-MDX
|
|
markdown: {
|
|
rehypePlugins: [
|
|
must("rehype-slug", rehypeSlug),
|
|
[must("rehype-autolink-headings", rehypeAutolinkHeadings), { behavior: "append" }],
|
|
must("rehype-paragraph-ids", rehypeParagraphIds),
|
|
],
|
|
},
|
|
});
|