text: import { defineDocumentType, makeSource } from "contentlayer/source-files";
  import { h } from "hastscript";
  import rehypeAutolinkHeadings from "rehype-autolink-headings";
  import rehypeSlug from "rehype-slug";
  
  export const Post = defineDocumentType(() => ({
    name: "Post",
    contentType: "mdx",
    filePathPattern: `**/*.mdx`,
    fields: {
      title: {
        type: "string",
        description: "The title of the post",
        required: true,
      },
      excerpt: {
        type: "string",
        description: "An excerpt of the post",
        required: true,
      },
      date: {
        type: "date",
        description: "The date of the post",
        required: true,
      },
    },
    computedFields: {
      url: {
        type: "string",
        resolve: (post) => `/blog/${post._raw.flattenedPath}`,
      },
    },
  }));
  
  export default makeSource({
    contentDirPath: "posts",
    documentTypes: [Post],
    mdx: {
      rehypePlugins: [
        rehypeSlug,
        [
          rehypeAutolinkHeadings,
          {
            behavior: "prepend",
            content: (node) => h("span", "#"),
          },
        ],
      ],
    },
  });
  