Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentlayer

Package Overview
Dependencies
Maintainers
1
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentlayer

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-18.66%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 28 Jun 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc