From 56597ef7ce7893b3cef30170ee4a062c9d0d95e0 Mon Sep 17 00:00:00 2001 From: pheralb Date: Tue, 1 Oct 2024 10:49:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20custom=20markdown=20plugin?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- svelte.config.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/svelte.config.js b/svelte.config.js index 83dc39f..aaa6f5c 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -7,11 +7,31 @@ import adapter from '@sveltejs/adapter-node'; import { mdsvex, escapeSvelte } from 'mdsvex'; import { createHighlighter, makeSingletonHighlighter } from 'shiki'; +// 🎨 Markdown Plugins: +import remarkGfm from 'remark-gfm'; +import rehypeAutolinkHeadings from 'rehype-autolink-headings'; +import rehypeSlug from 'rehype-slug'; + // 📄 Markdown config: const getHighlighter = makeSingletonHighlighter(createHighlighter); /** @type {import('mdsvex').MdsvexOptions} */ const mdsvexOptions = { + remarkPlugins: [[remarkGfm]], + rehypePlugins: [ + [rehypeSlug], + [ + rehypeAutolinkHeadings, + { + behavior: 'wrap', + properties: { + className: [ + `before:content-['#'] before:absolute before:-ml-[1em] before:text-neutral-100/0 hover:before:text-neutral-200/50 pl-[1em] -ml-[1em]` + ] + } + } + ] + ], extensions: ['.md'], highlight: { highlighter: async (code, lang = 'text') => {