diff --git a/astro.config.mts b/astro.config.mts index d56c033..794d6d7 100644 --- a/astro.config.mts +++ b/astro.config.mts @@ -1,6 +1,8 @@ import { defineConfig } from "astro/config"; import starlight from "@astrojs/starlight"; import starlightLinksValidator from "starlight-links-validator"; +import { rehypeHeadingIds } from "@astrojs/markdown-remark"; +import rehypeAutolinkHeadings from "rehype-autolink-headings"; // https://astro.build/config export default defineConfig({ @@ -21,7 +23,7 @@ export default defineConfig({ github: "https://github.com/Vencord", discord: "https://vencord.dev/discord" }, - customCss: ["./src/style/custom.css"], + customCss: ["./src/style/custom.css", "./src/style/headingLinks.css"], lastUpdated: true, sidebar: [ { @@ -38,5 +40,17 @@ export default defineConfig({ } ] }) - ] + ], + + markdown: { + rehypePlugins: [ + rehypeHeadingIds, + [ + rehypeAutolinkHeadings, + { + behavior: "wrap" + } + ] + ] + } }); diff --git a/package.json b/package.json index 1223ed3..661e9eb 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,10 @@ }, "dependencies": { "@astrojs/check": "^0.7.0", + "@astrojs/markdown-remark": "^5.1.1", "@astrojs/starlight": "^0.24.4", "astro": "^4.10.2", + "rehype-autolink-headings": "^7.1.0", "sharp": "^0.32.5", "starlight-links-validator": "^0.9.0", "typescript": "^5.5.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 08853d1..7fbbeac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,12 +11,18 @@ importers: '@astrojs/check': specifier: ^0.7.0 version: 0.7.0(typescript@5.5.2) + '@astrojs/markdown-remark': + specifier: ^5.1.1 + version: 5.1.1 '@astrojs/starlight': specifier: ^0.24.4 version: 0.24.4(astro@4.11.1(typescript@5.5.2)) astro: specifier: ^4.10.2 version: 4.11.1(typescript@5.5.2) + rehype-autolink-headings: + specifier: ^7.1.0 + version: 7.1.0 sharp: specifier: ^0.32.5 version: 0.32.6 @@ -1192,6 +1198,9 @@ packages: hast-util-has-property@3.0.0: resolution: {integrity: sha512-MNilsvEKLFpV604hwfhVStK0usFY/QmM5zX16bo7EjnAEGofr5YyI37kzopBlZJkHD4t887i+q/C8/tr5Q94cA==} + hast-util-heading-rank@3.0.0: + resolution: {integrity: sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==} + hast-util-is-body-ok-link@3.0.0: resolution: {integrity: sha512-VFHY5bo2nY8HiV6nir2ynmEB1XkxzuUffhEGeVx7orbu/B1KaGyeGgMZldvMVx5xWrDlLLG/kQ6YkJAMkBEx0w==} @@ -1820,6 +1829,9 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} + rehype-autolink-headings@7.1.0: + resolution: {integrity: sha512-rItO/pSdvnvsP4QRB1pmPiNHUskikqtPojZKJPPPAVx9Hj8i8TwMBhofrrAYRhYOOBZH9tgmG5lPqDLuIWPWmw==} + rehype-expressive-code@0.35.3: resolution: {integrity: sha512-kj43Rg+WzYUs8RRr6XyBr60pnrIZEgbmn9yJoV6qka1UDpcx7r8icn6Q2uSAgaLtlEUy+HCPgQJraOZrA53LOQ==} @@ -3655,6 +3667,10 @@ snapshots: dependencies: '@types/hast': 3.0.4 + hast-util-heading-rank@3.0.0: + dependencies: + '@types/hast': 3.0.4 + hast-util-is-body-ok-link@3.0.0: dependencies: '@types/hast': 3.0.4 @@ -4644,6 +4660,15 @@ snapshots: dependencies: picomatch: 2.3.1 + rehype-autolink-headings@7.1.0: + dependencies: + '@types/hast': 3.0.4 + '@ungap/structured-clone': 1.2.0 + hast-util-heading-rank: 3.0.0 + hast-util-is-element: 3.0.0 + unified: 11.0.5 + unist-util-visit: 5.0.0 + rehype-expressive-code@0.35.3: dependencies: expressive-code: 0.35.3 diff --git a/src/style/headingLinks.css b/src/style/headingLinks.css new file mode 100644 index 0000000..776b54f --- /dev/null +++ b/src/style/headingLinks.css @@ -0,0 +1,8 @@ +.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) > a { + color: var(--sl-color-white); + text-decoration: none; +} + +.sl-markdown-content :is(h1, h2, h3, h4, h5, h6) > a:hover { + text-decoration: underline; +}