Socket
Socket
Sign inDemoInstall

contentlayer

Package Overview
Dependencies
280
Maintainers
1
Versions
233
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    contentlayer


Version published
Weekly downloads
46K
increased by7.07%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Contentlayer

Contentlayer transforms content (e.g. Markdown or CMS content) into data you can easily import in your application.

NOTE: Contentlayer is still under heavy development and shouldn't be used in production yet.

Features

  • Supported content sources:
    • Local content (Markdown, MDX, JSON, YAML)
    • Contentful
    • Sanity
  • Simple but powerful schema DSL to design your content model
  • Auto-generated TypeScript types based on your content model (e.g. frontmatter)

Roadmap

  • More content sources:
    • Notion
    • GraphCMS
  • Incremental data fetching

Usage with Next.js

Install dependencies

  • Create contentlayer.config.ts file. Example
import { defineDocument, fromLocalContent } from 'contentlayer/source-local'
import highlight from 'rehype-highlight'

export const Post = defineDocument(() => ({
  name: 'Post',
  filePathPattern: `**/*.md`,
  fields: {
    title: {
      type: 'string',
      description: 'The title of the post',
      required: true,
    },
    date: {
      type: 'date',
      description: 'The date of the post',
      required: true,
    },
  },
  computedFields: {
    slug: { type: 'string', resolve: (_) => _._id.replace('.md', '') },
  },
}))

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

Usage via CLI

FAQs

Last updated on 05 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc