Currently running NextJS 13.3 in my application directory and attempting to implement contentlayer for serving my mdx files.
tsconfig.json
{
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"contentlayer/generated": ["./.contentlayer/generated"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".contentlayer/generated"],
}
contentlayer.config.js
import { defineDocumentType, makeSource } from 'contentlayer/source-files';
export const Post = defineDocumentType(() => ({
name: 'Post',
contentType: 'mdx',
filePathPattern: 'posts/*.mdx',
}));
export default makeSource({
contentDirPath: 'content',
documentTypes: [Post],
});
app/blog/[slug]/page.tsx
import { allPosts } from 'contentlayer/generated';
When trying to import, an error is triggered:
Error message: Cannot locate module 'contentlayer/generated' or its corresponding type declarations