Skip to content

Adds ability to override components from consuming app #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "next start"
},
"dependencies": {
"next": "^9.3.5",
"next": "^9.5.3",
"node-fetch": "^2.6.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
Expand Down
12 changes: 11 additions & 1 deletion example/pages/[pageId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";
import { NotionRenderer, BlockMapType } from "react-notion";
import Head from "next/head";
import Link from "next/link";
import fetch from "node-fetch";

export async function getServerSideProps(context) {
Expand Down Expand Up @@ -39,7 +41,15 @@ const NotionPage = ({ blockMap }) => {
<Head>
<title>{title}</title>
</Head>
<NotionRenderer blockMap={blockMap} fullPage />
<NotionRenderer
blockMap={blockMap}
fullPage
customBlockComponents={{
page: ({ blockValue, renderComponent }) => (
<Link href={`/${blockValue.id}`}>{renderComponent()}</Link>
)
}}
/>
<style jsx global>{`
div :global(.notion-code) {
box-sizing: border-box;
Expand Down
10 changes: 9 additions & 1 deletion example/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NotionRenderer, BlockMapType } from "react-notion";
import Head from "next/head";
import Link from "next/link";
import fetch from "node-fetch";

export async function getStaticProps() {
Expand All @@ -26,7 +27,14 @@ const Home = ({ blockMap }) => (
<Head>
<title>react-notion example</title>
</Head>
<NotionRenderer blockMap={blockMap} />
<NotionRenderer
blockMap={blockMap}
customBlockComponents={{
page: ({ blockValue, renderComponent }) => (
<Link href={`/${blockValue.id}`}>{renderComponent()}</Link>
)
}}
/>
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,7 @@ next-tick@~1.0.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=

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