Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🏗️ Build (push) Failing after 14s
Build & Deploy / 🧪 QA (push) Failing after 1m48s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
30 lines
911 B
TypeScript
30 lines
911 B
TypeScript
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'
|
|
|
|
export const Post = defineDocumentType(() => ({
|
|
name: 'Post',
|
|
filePathPattern: `blog/**/*.mdx`,
|
|
contentType: 'mdx',
|
|
fields: {
|
|
title: { type: 'string', required: true },
|
|
date: { type: 'string', required: true },
|
|
description: { type: 'string', required: true },
|
|
tags: { type: 'list', of: { type: 'string' }, required: true },
|
|
thumbnail: { type: 'string', required: false },
|
|
},
|
|
computedFields: {
|
|
slug: {
|
|
type: 'string',
|
|
resolve: (doc) => doc._raw.sourceFileName.replace(/\.mdx$/, ''),
|
|
},
|
|
url: {
|
|
type: 'string',
|
|
resolve: (post) => `/blog/${post._raw.sourceFileName.replace(/\.mdx$/, '')}`,
|
|
},
|
|
},
|
|
}))
|
|
|
|
export default makeSource({
|
|
contentDirPath: 'content',
|
|
documentTypes: [Post],
|
|
})
|