makeSource provides Contentlayer with the schema and configuration for your application.

Usage

The code calling makeSource should be placed in contentlayer.config.js.

// contentlayer.config.js

import { makeSource } from 'contentlayer-source-notion'

export default makeSource({
  /* options */
})

Options

client

The @notionhq/client instance or options to query the Notion API.

Example:

import { Client } from '@notionhq/client'
import { makeSource } from 'contentlayer-source-notion'

const client = new Client({ auth: process.env.NOTION_TOKEN })

export default makeSource({
  client,
})

This would use process.env.NOTION_TOKEN when calling the Notion API.

renderer

The @notion-render/client instance or options to transform Notion Block into HTML.

Example:

import { NotionRenderer } from '@notion-render/client'
import { makeSource } from 'contentlayer-source-notion'

const renderer = new NotionRenderer()

export default makeSource({
  renderer
})

databaseTypes

(required)

Your databases definitions for your project. See defineDatabase for usage.

fieldOptions

Provides the ability to manipulate how fields are written when parsing the content source.

Options:

  • bodyFieldName (default: body): Name of the field containing the body/content extracted when the body type is markdown or mdx.
  • typeFieldName (default: type): Name of the field containing the name of the document type.

Example:

export default makeSource({
  fieldOptions: {
    bodyFieldName: 'content',
    typeFieldName: '__typename',
  },
})

dev

Provides the ability to configure the development server when running contentlayer dev or next dev (with next-contentlayer).

Options:

  • polling (default: 5000): Delay in ms between each check for updated pages (can be set to false to disable).

Example:

export default makeSource({
  dev: {
    polling: 10_000
  },
})

⚠ Currently it does not update the schema, only your pages content and properties values.


Was this article helpful to you?
Provide feedback

Last edited on May 24, 2023.
Edit this page