-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
35 lines (33 loc) · 1.06 KB
/
next.config.js
File metadata and controls
35 lines (33 loc) · 1.06 KB
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
// next.config.js
const withMdxEnhanced = require("next-mdx-enhanced");
const readingTime = require("reading-time");
const containers = require("remark-containers");
const slug = require("remark-slug");
const headings = require("remark-autolink-headings");
const unwrap = require("remark-unwrap-images");
module.exports = withMdxEnhanced({
layoutPath: "layouts",
defaultLayout: true,
fileExtensions: ["mdx"],
remarkPlugins: [
containers,
slug,
[
headings,
{ behavior: "wrap", linkProperties: { className: "autolink-heading" } },
],
unwrap,
],
rehypePlugins: [],
extendFrontMatter: {
process: (mdxContent, frontMatter) => {
// Pretty bad implementation to strip HTML but good enough for this report
cleanText = mdxContent.replace(/<\/?[^>]+(>|$)/g, "");
const time = readingTime(cleanText);
time.words = frontMatter.title !== "Appendices" ? time.words - 44 : 0;
console.log({ title: frontMatter.title, ...time });
return { time };
},
phase: "both",
},
})(/* your normal nextjs config */);