import { serialize } from 'next-mdx-remote/serialize';
import readingTime from 'reading-time';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypePrettyCode from 'rehype-pretty-code';
/** @type {import('rehype-pretty-code').Options} */
const options = {
theme: 'one-dark-pro',
onVisitLine(node: any) {
if (node.children.length === 0) {
node.children = [{ type: 'text', value: ' ' }];
}
},
onVisitHighlightedLine(node: any) {
node.properties.className.push('line--highlighted');
},
onVisitHighlightedWord(node: any) {
node.properties.className = ['word--highlighted'];
},
};
export async function mdxToHtml(source: any) {
const mdxSource = await serialize(source, {
mdxOptions: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
[rehypePrettyCode, options],
[
rehypeAutolinkHeadings,
{
properties: {
className: ['anchor'],
},
},
],
],
format: 'mdx',
},
});
return {
html: mdxSource,
wordCount: source.split(/\s+/gu).length,
readingTime: readingTime(source).text,
};
}
got this error in vercel logs while building pages and i am using app router
ENOENT: no such file or directory, open '/var/task/node_modules/shiki/themes/one-dark-pro.json'
and i also install shiki package but shill get that same error message on vercel logs
when i build the code it will compile successfully but when i use ondemand revalidate through api like this function revalidatePath it give me error in vercel logs