Skip to content

Commit

Permalink
Use Next.js links for page links
Browse files Browse the repository at this point in the history
  • Loading branch information
timolins committed Sep 21, 2020
1 parent 8a77d24 commit 356f17a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
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
customComponents={{
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}
customComponents={{
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

0 comments on commit 356f17a

Please sign in to comment.