Skip to content

Commit

Permalink
feat(velite): create Posts collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfg7 committed Feb 24, 2024
1 parent 2cbb421 commit ae2a317
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions velite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineCollection, defineConfig, s } from 'velite'
import { slug } from '~/lib/slug'

const posts = defineCollection({
name: 'Post',
pattern: 'posts/**/*.mdx',
schema: s
.object({
title: s.string(),
date: s.isodate(),
lastUpdate: s.isodate().optional(),
description: s.string(),
category: s.string(),
tags: s
.string()
.transform(data => data.split(',').map(tag => tag.trim())),
status: s.enum(['published', 'draft', 'planned']).default('draft'),
test: s.boolean().default(false),
// content: s.mdx(),
metadata: s.metadata()
})
.transform(data => ({
...data,
slug: slug(data.title)
}))
})

const config = defineConfig({
collections: { posts }
})

export default config

0 comments on commit ae2a317

Please sign in to comment.