Next, we need to configure Litebook and provide Presta an entrypoint to render our pages.
Create an file called site.js
. Presta will use this file to build all your pages.
Then, set up a litebook
instance like litebook(docsBase, fileGlobs[, options])(__filename)
:
docsBase
is the root directory that contains your markdown files — URLs will
be resolved relative to this directoryfileGlobs
is a string
or string[]
that points to markdown files — if you
want to support nested pages, include a directory glob as well i.e.
**/*.md
import { litebook } from 'litebook'
const docs = litebook('./pages', '**/*.md')(__filename)
The
__filename
is important. It tellslitebook
andpresta
which file is declaring the docs theme.
Presta requires two exports, which litebook
provides you. Export those
and you're good to go!
import { litebook } from 'litebook'
const docs = litebook('./pages', '**/*.md')(__filename)
export const getStaticPaths = docs.getStaticPaths
export const handler = docs.handler
Then, just run npx presta watch site.js
in your terminal and you're ready to
start adding pages.