Files
firezone/website/next.config.mjs
2024-04-10 03:19:34 +00:00

86 lines
2.0 KiB
JavaScript

// Adds GitHub-flavored markdown support to MDX
import nextMDX from "@next/mdx";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import rehypeStringify from "rehype-stringify";
import rehypeHighlight from "rehype-highlight";
// Add IDs to headings
import rehypeSlug from "rehype-slug";
// Add anchor links to headings with IDs
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import { s } from "hastscript";
// Highlight.js languages
import langElixir from "highlight.js/lib/languages/elixir";
import langYaml from "highlight.js/lib/languages/yaml";
import langJson from "highlight.js/lib/languages/json";
import langBash from "highlight.js/lib/languages/bash";
import langRust from "highlight.js/lib/languages/rust";
import langRuby from "highlight.js/lib/languages/ruby";
const highlightLanguages = {
elixir: langElixir,
yaml: langYaml,
json: langJson,
bash: langBash,
rust: langRust,
ruby: langRuby,
};
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
typedRoutes: true,
},
// Proxy GitHub requests to avoid CORS issues
async rewrites() {
return [
{
source: "/api/github/:path*",
destination: "https://github.com/:path*",
},
];
},
pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"],
images: {
dangerouslyAllowSVG: true,
remotePatterns: [
{
hostname: "img.shields.io",
},
{
hostname: "github.com",
},
{
hostname: "avatars.githubusercontent.com",
},
{
hostname: "www.gravatar.com",
},
],
},
};
const withMDX = nextMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkGfm, remarkParse],
rehypePlugins: [
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: "wrap" }],
rehypeStringify,
[
rehypeHighlight,
{
ignoreMissing: true,
languages: highlightLanguages,
},
],
],
},
});
export default withMDX(nextConfig);