Giter Club home page Giter Club logo

contentlayer's Introduction

Contentlayer Discord

Contentlayer turns your content into data - making it super easy to import MD(X) and CMS content in your app

NOTE: Contentlayer is still in alpha and under active development. We expect to release a more stable beta version soon.

Try out an example

There are multiple example projects which you can clone to try out locally or in via Gitpod in your browser:

Gitpod ready-to-code

Features

  • Supported content sources:
    • Local content (Markdown, MDX, JSON, YAML)
    • Contentful
    • Sanity (experimental)
  • Live-reload on content changes
  • Fast and incremental builds (many times faster than Gatsby in most cases)
  • Simple but powerful schema DSL to design your content model (validates your content and generates types)
  • Auto-generated TypeScript types based on your content model (e.g. frontmatter or CMS schema)

Roadmap

  • Better getting started experience with auto-scaffolding of config file based on existing content files
  • Stackbit integration
  • Incremental data fetching for Contentful
  • More content sources:
    • Notion
    • GraphCMS
    • ...

Documentation

You can find the full documention for Contentlayer here.

Usage with Next.js

Install dependencies

npm install contentlayer next-contentlayer

Create contentlayer.config.ts file

import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import highlight from 'rehype-highlight'

export const Post = defineDocumentType(() => ({
  name: 'Post',
  filePathPattern: `**/*.md`,
  fields: {
    title: { type: 'string', required: true },
    date: { type: 'date' },
  },
}))

export default makeSource({
  contentDirPath: 'posts',
  documentTypes: [Post],
  markdown: { rehypePlugins: [highlight] },
})

Set up Next.js plugin in next.config.js (optional: enables live-reload and build setup)

const { withContentlayer } = require('next-contentlayer')

module.exports = withContentlayer()({
  // Your Next.js config...
})

Who is using Contentlayer?

Are you using Contentlayer? Please add yourself to the list above via a PR. ๐Ÿ™

contentlayer's People

Contributors

axeldelafosse avatar ghoshnirmalya avatar imadatyatalah avatar jahirfiquitiva avatar miryangjung avatar samuelkraft avatar schickling avatar souavds avatar tatchi avatar

Watchers

 avatar  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.