From 869a44dd0422395edf8540f28c6f0e2af3f52b24 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Thu, 22 Dec 2022 23:19:38 +0100 Subject: [PATCH] autolink headings --- website/astro.config.mjs | 15 ++++++++- website/package.json | 5 ++- website/src/components/Header/Header.astro | 2 +- website/src/docs/docs.css | 36 ++++++++++++++++++++++ website/src/docs/link.svg | 5 +++ website/src/layouts/MainLayout.astro | 1 + 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 website/src/docs/docs.css create mode 100644 website/src/docs/link.svg diff --git a/website/astro.config.mjs b/website/astro.config.mjs index f18ae37a..873712b1 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -5,11 +5,24 @@ import react from '@astrojs/react'; // https://astro.build/config import mdx from '@astrojs/mdx'; +import remarkToc from 'remark-toc'; +import rehypeSlug from 'rehype-slug'; +import rehypeAutolinkHeadings from 'rehype-autolink-headings'; + // https://astro.build/config // https://astro.build/config import tailwind from '@astrojs/tailwind'; +const options = { + // See https://mdxjs.com/advanced/plugins + remarkPlugins: [ + remarkToc, + // E.g. `remark-frontmatter` + ], + rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings], +}; + // https://astro.build/config export default defineConfig({ integrations: [ @@ -17,7 +30,7 @@ export default defineConfig({ preact(), // Enable React for the Algolia search component. react(), - mdx(), + mdx(options), tailwind(), ], site: `https://strudel.tidalcycles.org`, diff --git a/website/package.json b/website/package.json index 47d39d07..7319cce3 100644 --- a/website/package.json +++ b/website/package.json @@ -30,7 +30,10 @@ "tailwindcss": "^3.2.4", "@heroicons/react": "^2.0.13", "@supabase/supabase-js": "^1.35.3", - "nanoid": "^4.0.0" + "nanoid": "^4.0.0", + "rehype-autolink-headings": "^6.1.1", + "rehype-slug": "^5.0.1", + "remark-toc": "^8.0.1" }, "devDependencies": { "html-escaper": "^3.0.3" diff --git a/website/src/components/Header/Header.astro b/website/src/components/Header/Header.astro index c7f672c8..a84b1a8e 100644 --- a/website/src/components/Header/Header.astro +++ b/website/src/components/Header/Header.astro @@ -15,7 +15,7 @@ const { currentPage } = Astro.props as Props; // const lang = getLanguageFromURL(currentPage); --- -