-
-
Notifications
You must be signed in to change notification settings - Fork 615
/
Copy pathnext.config.js
52 lines (49 loc) · 1.69 KB
/
next.config.js
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
const svgr = require('next-plugin-svgr');
const createMdx = require('next-mdx-enhanced');
const withPlugins = require('next-compose-plugins');
const slug = require('rehype-slug');
const autolinkHeadings = require('rehype-autolink-headings');
const prism = require('remark-prism');
const remarked = require('remarked');
const cheerio = require('cheerio');
const images = require('next-images');
const mdx = createMdx({
fileExtensions: ['md', 'mdx'],
rehypePlugins: [
slug,
[
autolinkHeadings,
{
behavior: 'append',
properties: {
className: 'text-white ml-2 no-underline opacity-70 md-autolink',
},
content: {
type: 'element',
tagName: 'span',
properties: { className: ['text-gray-700'] },
children: [{ type: 'text', value: '#' }],
},
},
],
],
remarkPlugins: [prism],
extendFrontMatter: {
// autodetects title and adds it to frontMatter
process: (mdxContent, frontMatter) => {
const content = remarked(mdxContent);
const $ = cheerio.load(content);
const title = $('h1:first-of-type').text();
frontMatter.title = title;
return frontMatter;
},
},
defaultLayout: true,
layoutPath: 'src/layouts',
});
module.exports = withPlugins([mdx, svgr, [images, { fileExtensions: ['jpg', 'jpeg', 'png', 'gif'] }]], {
pageExtensions: ['js', 'jsx', 'mdx', 'md'],
trailingSlash: true,
// mdx-enhanced does not play nice (yet) with webpack5 it seems...
webpack5: false,
});