Replies: 2 comments 4 replies
-
|
You don't need to write code for each route. Simply create a file and define exports for all your filters, such as import { allPosts } from "content-collections";
export const drafts = allPosts.filter(p => !p.published);
export const published = allPosts.filter(p => p.published);Then, import the filtered collections wherever you need them: import { published } from "./posts";It's similar to sorting. Please take a look at the docs. We might also consider adding filtering to the documentation. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thanks I'll do something like this. I just thought it would be better to skip processing these files, instead of processing them and then filtering them out. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be great to exclude or filter based on frontmatter, not only glob pattern. This means we could handle drafts at the content collection level, and avoid writing JavaScript filters for each route.
e.g.:
Beta Was this translation helpful? Give feedback.
All reactions