// import { defineDocumentType, makeSource } from 'contentlayer/source-files'

// const Post = defineDocumentType(() => ({
//   name: 'Post',
//   filePathPattern: `**/*.mdx`,
//   contentType: 'mdx',
//   fields: {
//     title: {
//       type: 'string',
//       description: 'The title of the post',
//       required: true,
//     },
//     date: {
//       type: 'date',
//       description: 'The date of the post',
//       required: true,
//     },
//   },
//   computedFields: {
//     url: {
//       type: 'string',
//       resolve: (doc) => `/posts/${doc._raw.flattenedPath}`,
//     },
//   },
// }))

// export default makeSource({
//   contentDirPath: 'posts',
//   documentTypes: [Post],
// })



import { defineDocumentType, makeSource } from 'contentlayer/source-files'

export const Post = defineDocumentType(() => ({
  name: 'Post',
  filePathPattern: `**/*.mdx`,
  contentType: 'mdx',
  fields: {
    title: { type: 'string', required: true },
    date: { type: 'date', required: true },
    description: { type: 'string', required: true },
    tags: { type: 'list', of: { type: 'string' }, default: [] },
    coverImage: { type: 'string' },
  },
  computedFields: {
    url: { type: 'string', resolve: (post) => `/posts/${post._raw.flattenedPath}` },
  },
}))

export default makeSource({
  contentDirPath: 'posts',
  documentTypes: [Post],
})
