Closed
Description
I'm trying to configure my blogs/docs using contentlayer
in a Next.js project.
"next": "14.2.5",
"contentlayer": "^0.3.4",
"next-contentlayer": "^0.3.4",
When I run yarn contentlayer build
or yarn contentlayer dev
, I receive the following error:
Warning: Contentlayer might not work as expected on Windows
Could not find contentlayer.config.ts or contentlayer.config.js in `your source`
The contentlayer.config.js
file is located at the root of my project, and my configuration looks like this:
import { defineDocumentType, makeSource } from "contentlayer/source-files";
/** @type {import('contentlayer/source-files').ComputedFields} */
const computedFields = {
slug: {
type: "string",
resolve: (doc) => `/${doc._raw.flattenedPath}`,
},
slugAsParams: {
type: "string",
resolve: (doc) => doc._raw.flattenedPath.split("/").slice(1).join("/"),
},
};
export const Doc = defineDocumentType(() => ({
name: "Doc",
filePathPattern: `docs/**/*.mdx`,
contentType: "mdx",
fields: {
title: {
type: "string",
required: true,
},
description: {
type: "string",
},
published: {
type: "boolean",
default: true,
},
},
computedFields,
}));
export default makeSource({
contentDirPath: "./content",
documentTypes: [Doc]
});
Here’s my directory structure:
project
├── app
├── package.json
├── contentlayer.config.js
├── tsconfig.json
└── ...rest
Is contentlayer
not compatible with the latest Next.js version, or is there something wrong with my configuration? Any help would be appreciated!