Giter Site home page Giter Site logo

bigok666 / content-collections Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sdorra/content-collections

0.0 0.0 0.0 4.61 MB

Transform your content into type-safe data collections

Home Page: https://content-collections.dev

License: MIT License

Shell 0.03% JavaScript 0.78% TypeScript 98.72% CSS 0.47%

content-collections's Introduction

Content Collections

logo: A staple of books

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.

  • Tansformation: 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

  1. Create a content-collections.ts file at the root of your project:

    import { defineCollection, defineConfig } from "@content-collections/core";
    
    const posts = defineCollection({
      name: "posts",
      directory: "src/posts",
      include: "**/*.md",
      schema: (z) => ({
        title: z.string(),
        summary: z.string(),
      }),
    });
    
    export default defineConfig({
      collections: [posts],
    });
  2. Start writing content in src/posts:

    ---
    title: Hello World
    summary: This is my first post
    ---
    
    # Hello World
    
    This is my first post.
  3. Use your content in your app:

    import { allPosts } from "content-collections";
    
    export function Posts() {
      return (
        <ul>
          {allPosts.map((post) => (
            <li key={post._meta.path}>
              <a href={`/posts/${post._meta.path}`}>
                <h3>{post.title}</h3>
                <p>{post.summary}</p>
              </a>
            </li>
          ))}
        </ul>
      );
    }

    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

supastarter    Cloudogu GmbH

License

Content Collections is licensed under the MIT License.

content-collections's People

Contributors

sdorra avatar dependabot[bot] avatar jonathanwilke avatar marviuz avatar chopfitzroy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.