-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathnext.config.mjs
58 lines (53 loc) · 1.32 KB
/
next.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import fs from 'fs';
import path from 'path';
import { visit } from 'unist-util-visit';
import { u } from 'unist-builder';
import remarkGfm from 'remark-gfm';
import createMDX from '@next/mdx';
import { remarkCodeHike, recmaCodeHike } from 'codehike/mdx';
import rehypeSlug from 'rehype-slug';
// Import the JSON file
// Import the JSON file
const docsData = JSON.parse(
fs.readFileSync(path.resolve('./configs/docs.json'), 'utf8')
);
const { dataArray } = docsData;
const chConfig = {
components: { code: 'PreCode' },
};
function rehypeComponent() {
return (tree) => {
visit(tree, (node) => {});
};
}
const withMDX = createMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkGfm, [remarkCodeHike, chConfig]],
recmaPlugins: [[recmaCodeHike, chConfig]],
rehypePlugins: [rehypeSlug, rehypeComponent],
jsx: true,
},
});
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
images: {
remotePatterns: [
{
hostname: 'avatars.githubusercontent.com',
},
{
hostname: 'res.cloudinary.com',
},
{
hostname: 'images.unsplash.com',
},
{
hostname: 'img.freepik.com',
},
],
},
// Add other Next.js config options here
};
export default withMDX(nextConfig);