📄
Configuring your .env
notion2svelte expects to find a .env file in the directory where it’s run (typically the root of your SvelteKit directory). At minimum, this file — which should not be checked into source control! — must contain your Notion API key.

Required key

NOTION_API_KEY=secret_QoIn8edvksjn…
  typescript
In order to fetch data from your Notion account, notion2svelte needs a “secret,” which you can generate by following these instructions.
notion2svelte is designed to interface with your pages via a Notion database, so make sure that said database is connected to whatever secret you use for NOTION_API_KEY via a Notion “Integration”.

Optional keys

Regular use

PUBLISHABLE_STATUS=Publishable
OUTPUT_PATH=
OUTPUT_STATIC_FOLDER=
  typescript
Default values if left unset
PUBLISHABLE_STATUS defines the string that notion2svelte uses to filter against your pages’ Status prop; if Status is not set to (by default) Publishable, the page won’t be included.
OUTPUT_PATH tells notion2svelte where to save .svelte files. If left empty (the default), notion2svelte will output to the current directory.
OUTPUT_STATIC_FOLDER tells notion2svelte where to save media files, esp. images. Again, the default is empty, meaning images will be stored in ./static//…

Debugging

While building notion2svelte, I found myself frequently needing to rerun the tool repeatedly on a single page.
Since the content of that page often didn’t change much, I also found myself wanting to run the JSON→.svelte conversion without re-fetching each time. Thus were born these last three options:
NOTION_TEST_PAGE_ID=b0f0dfbbthisisfakecd9039c7466476
CACHE_TOKEN=b0f0dfbbthisisfakecd9039c7466476
# FORCE_REFRESH=true
  typescript
NOTION_TEST_PAGE_ID skips the pages-from-database loop, and fetches just the one page specified.
CACHE_TOKEN tells notion2svelte whether it should fetch the test page:
If the cache token matches the test page id, notion2svelte will skip fetching, and instead read the JSON directly from the locally-stored* intermediary output.
It’s a bit of a hack because notion2svelte actually updates the CACHE_TOKEN in your .env every time a test page is fetched. It seems wrong to have a tool editing its own .env file, but it worked and it was easy, so for now, this is how it works. ¯\_(ツ)_/¯
FORCE_REFRESH, when set to true, tells notion2svelte to ignore the cache token & hit the Notion API every time.
 
*In notion2svelte 0.2.0, a /notion-export.js file is output next to every /+page.svelte page, just for kicks (and to help me troubleshoot notion2svelte rendering issues).
Fancy horizontal divider

🏠 Browse the docs ⚘

High-level Discussion

Turn-intoable Block Components

Toggle Headings (not yet implemented)

Layout-only Components

Page-level Components

Annotation Components

bold → <strong>

italic → <em>

strikethrough → <s>

Other Components