-
Notifications
You must be signed in to change notification settings - Fork 194
Closed
Milestone
Description
/** @type {import('contentlayer/source-files').ComputedFields} */
const computedFields = {
slug: {
type: "string",
resolve: (doc: { _raw: { flattenedPath: never } }) =>
`/${doc._raw.flattenedPath}`,
},
slugAsParams: {
type: "string",
resolve: (doc: { _raw: { flattenedPath: string } }) =>
doc._raw.flattenedPath.split("/").slice(1).join("/"),
},
};
export const Posts = defineDocumentType(() => ({
name: "Posts",
filePathPattern: `posts/**/*.mdx`,
contentType: "mdx",
fields: {
title: {
type: "string",
required: true,
},
description: {
type: "string",
},
date: {
type: "date",
required: true,
},
published: {
type: "boolean",
default: true,
},
image: {
type: "string",
required: true,
},
visibility: {
type: "string",
required: true,
},
authors: {
// Reference types are not embedded.
// Until this is fixed, we can use a simple list.
// type: "reference",
// of: Author,
type: "list",
of: { type: "string" },
required: true,
},
},
// @ts-expect-error TODO: it's conflict with extracted computedFields (This would introduce the error)
computedFields,
}));By using the code of the above in contentlayer.config.ts it gives type error. However putting the constant object back fixes this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels