Skip to content

Commit ff67c78

Browse files
authored
Merge pull request #30 from cball/cb-custom-components
Adds ability to override components from consuming app
2 parents 59f5f49 + a8d7b3a commit ff67c78

File tree

7 files changed

+500
-369
lines changed

7 files changed

+500
-369
lines changed

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"start": "next start"
1111
},
1212
"dependencies": {
13-
"next": "^9.3.5",
13+
"next": "^9.5.3",
1414
"node-fetch": "^2.6.0",
1515
"react": "^16.13.1",
1616
"react-dom": "^16.13.1",

example/pages/[pageId].tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import React from "react";
12
import { NotionRenderer, BlockMapType } from "react-notion";
23
import Head from "next/head";
4+
import Link from "next/link";
35
import fetch from "node-fetch";
46

57
export async function getServerSideProps(context) {
@@ -39,7 +41,15 @@ const NotionPage = ({ blockMap }) => {
3941
<Head>
4042
<title>{title}</title>
4143
</Head>
42-
<NotionRenderer blockMap={blockMap} fullPage />
44+
<NotionRenderer
45+
blockMap={blockMap}
46+
fullPage
47+
customBlockComponents={{
48+
page: ({ blockValue, renderComponent }) => (
49+
<Link href={`/${blockValue.id}`}>{renderComponent()}</Link>
50+
)
51+
}}
52+
/>
4353
<style jsx global>{`
4454
div :global(.notion-code) {
4555
box-sizing: border-box;

example/pages/index.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NotionRenderer, BlockMapType } from "react-notion";
22
import Head from "next/head";
3+
import Link from "next/link";
34
import fetch from "node-fetch";
45

56
export async function getStaticProps() {
@@ -26,7 +27,14 @@ const Home = ({ blockMap }) => (
2627
<Head>
2728
<title>react-notion example</title>
2829
</Head>
29-
<NotionRenderer blockMap={blockMap} />
30+
<NotionRenderer
31+
blockMap={blockMap}
32+
customBlockComponents={{
33+
page: ({ blockValue, renderComponent }) => (
34+
<Link href={`/${blockValue.id}`}>{renderComponent()}</Link>
35+
)
36+
}}
37+
/>
3038
</div>
3139
);
3240

example/yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,7 @@ next-tick@~1.0.0:
33103310
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
33113311
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
33123312

3313-
next@^9.3.5:
3313+
next@^9.5.3:
33143314
version "9.5.3"
33153315
resolved "https://registry.yarnpkg.com/next/-/next-9.5.3.tgz#7af5270631f98d330a7f75a6e8e1ac202aa155e2"
33163316
integrity sha512-DGrpTNGV2RNMwLaSzpgbkbaUuVk30X71/roXHS10isSXo2Gm+qWcjonDyOxf1KmOvHZRHA/Fa+LaAR7ysdYS3A==

0 commit comments

Comments
 (0)