Replies: 1 comment
-
Async is only an internal API for testing, it is not supposed to be used in production |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
what's the coding "difference" between async : true and async : false?
experiment shows
when async: true
console.log(pages) shows
date: z.date().or(... won't be called(?) and i got the original page.data.date field value as in mdx file
when async: false
the console.log(pages) shows new validated value will be in page.data.date
I check the online document and can't figure out the correct way of handling this.
// source.config.ts
export const blog = defineCollections({
type: "doc",
dir: "content/blog",
//async: true,
schema: frontmatterSchema.extend({
date: z.date().or(
z
.string()
.transform((s) => new Date(s))
.default(new Date().toISOString())
),
}),
});
// app/[lang]/(home)/blog/page.tsx
export default async function BlogIndex(props: {
params: Promise<{ slug?: string[]; lang: string }>;
}) {
const params = await props.params;
const pages = blog
.getPages(params.lang)
.sort(
(a, b) =>
new Date(b.data.date ?? b.file.name).getTime() -
new Date(a.data.date ?? a.file.name).getTime()
);
console.log(pages);
...
Beta Was this translation helpful? Give feedback.
All reactions