Skip to content

Render a notion page #385

Closed Answered by mariosimao
jeff1985 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jeff1985!

The notion-sdk-php has a Markdown renderer.

<?php

require "vendor/autoload.php";

use Notion\Blocks\Renderer\MarkdownRenderer;
use Notion\Notion;

$token = "secret_token";
$notion = Notion::create($token);

$pageId = "page_id";
$blocks = $notion->blocks()->findChildrenRecursive($pageId);

echo PHP_EOL;
echo MarkdownRenderer::render(...$blocks);

The feature could mixed with a Markdown to HTML converter like CommonMark.

For more info, see #197

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mariosimao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants