-
-
Notifications
You must be signed in to change notification settings - Fork 724
Description
Environment
Nuxt project info: 11:18:23 AM
- Operating System: Linux
- Node Version: v20.12.2
- Nuxt Version: 3.14.1592
- CLI Version: 3.17.1
- Nitro Version: 2.10.4
- Package Manager: [email protected]
- Builder: -
- User Config: default
- Runtime Modules: @nuxt/[email protected], @nuxtjs/[email protected], @nuxt/[email protected]
- Build Modules: -
Reproduction
- Using the config below: content.config.ts
import {defineCollection, defineContentConfig, z} from '@nuxt/content'
export default defineContentConfig({
collections: {
blog: defineCollection({
// Load every file inside the `content` directory
source: 'blog/**',
// Specify the type of content in this collection
type: 'page',
schema: z.object({
badge: z.string(),
image: z.string(),
tags: z.array(z.string()),
published: z.boolean(),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
})
}),
}
})- Code
if (options.published !== undefined) {
// zod use 1 and 0 as boolean
const published = options.published ? 1 : 0;
query = query.where("published", '=', published);
}
if (options.latest !== undefined) {
query = query.order('updatedAt', "DESC")
}- Markdown
---
title: Example title
description: This is example description
badge:
image: /assets/images/coming-soon.jpg
tags:
- Example
published: false
createdAt: 2025-01-01 00:00
updatedAt: 2025-01-01 00:00
---
## Example title
Nothing here yet. Comeback later.Bugs:
1. order() not able to use the field in schemas
2. z.boolean() result to numberr 0/1 not boolean false/ true
Describe the bug
1. Bug 1: order() not able to use the field in schemas
When using order with field in schemas it show the below error
Argument of type 'string' is not assignable to parameter of type 'keyof Collections[T]'.
Type '"updatedAt"' is not assignable to type '"extension" | "path" | "title" | "description" | "seo" | "body" | "navigation" | "id" | "stem" | "meta"'.
2. Bug 2: z.boolean() result to numberr 0/1 not boolean false/ true

Additional context
I also see that nuxt/content don't have any total attribute when get from collection so that I can't create paginate and skip() will be useless because it can't count and paginate

