-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.ts
89 lines (83 loc) · 2.32 KB
/
next.config.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import bundleAnalyzer from "@next/bundle-analyzer";
import createMDX from "@next/mdx";
import {
remarkHeadings,
remarkMdxFrontmatter,
remarkMdxLayout,
remarkMdxPre,
remarkMdxSlug,
remarkStaticImage,
} from "@repo/remark-plugins";
import withSerwistInit from "@serwist/next";
import { rehypeGithubAlerts } from "rehype-github-alerts";
import remarkFrontmatter from "remark-frontmatter";
import remarkGfm from "remark-gfm";
import remarkGithub from "remark-github";
import { WEBSITE } from "~/constants";
import type { Metadata, NextConfig } from "next";
import type { VFile } from "vfile";
const withBundleAnalyzer = bundleAnalyzer({
// eslint-disable-next-line n/prefer-global/process
enabled: process.env.ANALYZE === "true",
});
const withSerwist = withSerwistInit({
swSrc: "src/sw.ts",
swDest: "public/sw.js",
});
const withMDX = createMDX({
extension: /\.mdx?$/,
options: {
remarkPlugins: [
[remarkHeadings, { isRemoteContent: false }],
remarkMdxSlug,
remarkGfm,
[remarkGithub, {}],
remarkFrontmatter,
[
remarkMdxFrontmatter,
{
name: "metadata",
format: (data: any, file: VFile) => {
const title = `Posts | ${data.title}`;
return {
title,
openGraph: {
url: `${WEBSITE.domain}/posts`,
title: `${file.data.title}` || title,
description: WEBSITE.description,
type: "website",
images: [
{
alt: `og-image-${file.data.slug}`,
url: `/posts/og/${file.data.slug}.png`,
width: 800,
height: 400,
},
],
emails: [WEBSITE.email],
},
} satisfies Metadata;
},
},
],
remarkMdxPre,
[remarkStaticImage, { importPrefix: "" }],
remarkMdxLayout,
],
rehypePlugins: [rehypeGithubAlerts],
},
});
const nextConfig: NextConfig = {
output: "export",
cleanDistDir: true,
reactStrictMode: true,
poweredByHeader: false,
images: {
unoptimized: true,
},
pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"],
};
export default [withBundleAnalyzer, withSerwist, withMDX].reduce(
(config, fn) => fn(config),
nextConfig,
);