web/lukegbcom: install rehype-toc and rehype-slug, and add "nix" syntax highlighting

This commit is contained in:
Luke Granger-Brown 2023-08-19 14:51:28 +00:00
parent 0991cea3c3
commit 7a74b23304

View file

@ -1,21 +1,28 @@
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
import matter from 'gray-matter' import matter from 'gray-matter'
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import remarkRehype from 'remark-rehype'
import rehypeHighlight from 'rehype-highlight' import rehypeHighlight from 'rehype-highlight'
import rehypeStringify from 'rehype-stringify' import rehypeSlug from 'rehype-slug'
import remarkToc from 'remark-toc'
import nix from 'highlight.js/lib/languages/nix'
const fsPromises = fs.promises const fsPromises = fs.promises
const postsDirectory = path.join(process.cwd(), 'posts') const postsDirectory = path.join(process.cwd(), 'posts')
export const mdxOptions = { export const mdxOptions = {
remarkPlugins: [remarkGfm], remarkPlugins: [
rehypePlugins: [rehypeHighlight], remarkGfm,
[remarkToc, {tight: true}],
],
rehypePlugins: [
[rehypeHighlight, {languages: {nix}}],
rehypeSlug,
],
}; };
export async function getPostSlugs() { export async function getPostSlugs() {