Installations
npm install @content-collections/core
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
20.18.1
NPM Version
10.8.2
Score
67.8
Supply Chain
90.8
Quality
84.1
Maintenance
50
Vulnerability
98.9
License
Releases
Unable to fetch releases
Love this project? Help keep it running — sponsor us today! 🚀
Download Statistics
Total Downloads
315,996
Last Day
2,096
Last Week
12,921
Last Month
53,144
Last Year
315,686
Package Meta Information
Latest Version
0.8.0
Package Id
@content-collections/core@0.8.0
Unpacked Size
53.06 kB
Size
13.99 kB
File Count
5
NPM Version
10.8.2
Node Version
20.18.1
Published on
Dec 18, 2024
Total Downloads
Cumulative downloads
Total Downloads
315,996
Last Day
5%
2,096
Compared to previous day
Last Week
-10.3%
12,921
Compared to previous week
Last Month
33.8%
53,144
Compared to previous month
Last Year
101,734.2%
315,686
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Content Collections

Transform your content into type-safe data collections. Eliminate the need for manual data fetching and parsing. Simply import your content and begin. Built-in validation ensures the accuracy of your data. Preprocess your data before it enters your app.
Features
-
Beautiful DX: Content Collections is designed to provide a pleasurable user experience. It offers a seamless developer experience without the need to restart the server or refresh the browser. Content collections are automatically updated when you make changes to your content.
-
Type-safe: Your content is parsed and validated during the build process, guaranteeing accuracy and currency. Content Collections offers a type-safe API to access your content.
-
Simple to use: No need to manually fetch and parse your content anymore. Just import it and start using Content Collections. It provides a simple API, allowing you to concentrate on building your app.
-
Transformation: Content Collections allows you to transform your content before it enters your app. You can use it to modify your content, join two collections or even fetch data from a server.
Installation
Content Collections offers a variety of adapters that seamlessly integrate with popular web frameworks. The installation process depends on the chosen adapter:
If your framework is not listed, you can still use Content Collections by using the CLI. Please open a ticket if you want to see your framework listed.
Usage
-
Create a content-collections.ts file at the root of your project:
1import { defineCollection, defineConfig } from "@content-collections/core"; 2 3const posts = defineCollection({ 4 name: "posts", 5 directory: "src/posts", 6 include: "**/*.md", 7 schema: (z) => ({ 8 title: z.string(), 9 summary: z.string(), 10 }), 11}); 12 13export default defineConfig({ 14 collections: [posts], 15});
-
Start writing content in
src/posts
:1--- 2title: Hello World 3summary: This is my first post 4--- 5 6# Hello World 7 8This is my first post.
-
Use your content in your app:
1import { allPosts } from "content-collections"; 2 3export function Posts() { 4 return ( 5 <ul> 6 {allPosts.map((post) => ( 7 <li key={post._meta.path}> 8 <a href={`/posts/${post._meta.path}`}> 9 <h3>{post.title}</h3> 10 <p>{post.summary}</p> 11 </a> 12 </li> 13 ))} 14 </ul> 15 ); 16}
Please note that the example above shows only the very basics of Content Collections and it does not cover content transformation. Content Collections does not transform content like markdown or mdx by default. But it has packages which can do that for you:
If you want to see more examples and use cases, please refer to the documentation.
Sponsors

Become a sponsor
License
Content Collections is licensed under the MIT License.

No vulnerabilities found.

No security vulnerabilities found.