Installation
Install with your preferred package manager:
sh
$ npm install -D contentkit
sh
$ pnpm add -D contentkit
sh
$ yarn add -D contentkit
sh
$ bun add -D contentkit
Initialize a config:
bash
npx contentkit init
bash
pnpm exec contentkit init
bash
yarn contentkit init
bash
bunx contentkit init
This creates contentkit.config.ts
(or .js
) based on environment.
Add a sample document:
bash
mkdir -p content
printf "---\ntitle: Hello World\ndate: 2025-01-01\ntags: [intro]\n---\n\nMy first post." > content/hello-world.md
powershell
New-Item -ItemType Directory -Force -Path content | Out-Null
@"
---
title: Hello World
date: 2025-01-01
tags: [intro]
---
My first post.
"@ | Set-Content content/hello-world.md
Build:
bash
npx contentkit build
bash
pnpm exec contentkit build
bash
yarn contentkit build
bash
bunx contentkit build
Generated artifacts live in .contentkit/generated
and a virtual package dot-contentkit
is written. Now we will add the dot-contentkit
package to our project.
First, open your tsconfig.json
(or jsconfig.json
) file and add the following path mapping:
jsonc
{
"compilerOptions": {
"paths": {
"dot-contentkit": [".contentkit/generated"],
},
},
}
jsonc
{
"compilerOptions": {
"paths": {
"dot-contentkit": [".contentkit/generated"],
},
},
}