Configure databases
⚠ The content source plugin contentlayer-source-notion
is currently in Alpha and should not be used in production.
Base configuration
name
of the generated schema and constants (e.g.allCategories
)description
used to generate commentsdatabase_id
of the database you want to query
const Category = defineDatabase(() => ({
name: 'Category',
databaseId: '<database_id>',
description: 'Categories used to group posts',
}))
Properties configuration
Even if your schema is automatically inferred you can configure properties to:
- Map properties to different keys in the generated schema
- Configure complex properties like "Rollup" and "Relation"
- Define required properties
More information on the dedicated page Configure properties.
const Category = defineDatabase(() => ({
name: 'Post',
databaseId: '<database_id>',
properties: {
author: {
name: 'Created by',
},
metaDescription: {
name: 'Short description',
},
},
}))
Disable content importation
By setting importContent
to false
, the content of your pages will not be queried.
It is extremely useful when you only need the properties of your pages and want to keep good performances.
const Category = defineDatabase(() => ({
name: 'Category',
databaseId: '<database_id>',
importContent: false,
}))
Disable automatic properties importation
By setting automaticImport
to false
, only the properties defined in the properties
parameter will be generated.
It is useful when your pages contains properties with sensible information you do not want to have in your generated content.
const Category = defineDatabase(() => ({
name: 'Category',
databaseId: '<database_id>',
automaticImport: false,
properties: {
email: {
name: 'Email',
},
},
}))
Filter and sort queried pages
You can filter and sort pages that are queried from your database by using the query
parameter.
You can find more information on the Notion API documentation.
const Category = defineDatabase(() => ({
name: 'Category',
databaseId: '<database_id>',
query: {
filter: {
property: 'Status',
status: {
equals: 'Published',
},
},
sort: [
{
property: 'Name',
direction: 'ascending',
},
],
},
}))
Was this article helpful to you?
Provide feedback
Last edited on April 01, 2024.
Edit this page