supMDX/next.config.mjs

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-11-04 21:44:29 +09:00
import mdx from '@next/mdx';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
2022-11-05 21:50:21 +09:00
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
2022-11-04 21:44:29 +09:00
import ExportHeadings from '@sup39/rehype-mdx-export-headings';
import ComponentWrapper from '@sup39/rehype-mdx-component-wrapper';
2023-02-16 23:55:50 +09:00
import AutoImport from '@sup39/rehype-mdx-auto-import';
2022-11-04 21:44:29 +09:00
const withMDX = mdx({
extension: /\.mdx?$/,
options: {
remarkPlugins: [
remarkFrontmatter,
2022-11-05 21:50:21 +09:00
remarkGfm,
remarkMath,
[remarkMdxFrontmatter, {name: 'meta'}],
2022-11-04 21:44:29 +09:00
],
rehypePlugins: [
2022-11-05 21:50:21 +09:00
rehypeKatex,
[ExportHeadings, {tags: ['h2'], name: 'headings'}],
[ComponentWrapper, {props: ['headings', 'meta']}],
2023-02-16 23:55:50 +09:00
[AutoImport,
{
import: ['T', 'S', 'C'],
from: '@sup39/mdx-components',
},
],
2022-11-04 21:44:29 +09:00
],
},
});
export default withMDX({
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
trailingSlash: true,
webpack(config) {
config.module.rules.push({
test: /\.ya?ml$/,
use: 'yaml-loader',
});
return config;
},
});