diff --git a/README.md b/README.md index 2d26f27..30d08fe 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ _This package doesn't handle the communication with the API. Check out [notion-a Created by Timo Lins & Tobias Lins with the help of all contributors ❤️ - - ## Features ⚡️ **Fast** – Up to 10x faster than Notion\* @@ -25,10 +23,8 @@ _This package doesn't handle the communication with the API. Check out [notion-a _\* First Meaningful Paint compared to a [hosted example](http://react-notion-example.now.sh/) on [Vercel](https://vercel.com)._ - **react-notion** is best suited as minimal renderer for blogs & content pages. If you're looking for a full-featured solution to render Notion-like pages, check out [react-notion-x](https://github.com/NotionX/react-notion-x). - ## Install ```bash @@ -134,7 +130,7 @@ This tends to be an issue for those using `react-notion` in a `next.js` project. To ensure the programming language is correctly highlighted in production builds, one should explicitly imported into the project. ```jsx -import 'prismjs/components/prism-{language}'; +import "prismjs/components/prism-{language}"; ``` ## Credits @@ -143,3 +139,44 @@ import 'prismjs/components/prism-{language}'; - [Timo Lins](https://timo.sh) – Code, Documentation - [samwightt](https://github.com/samwightt) – Inspiration & API Typings - [All people that contributed 💕](https://github.com/splitbee/react-notion/graphs/contributors) + +
+
+ +## Fixed + +- content is undefined error fix + +### 1. add your project patches folder + +
+ +### 2. install patch-package + +``` +yarn add patch-package +``` + +
+ +### 3. remove node-modules + +``` +rm -rf node_modules +``` + +
+ +### 4. reinstall + +``` +yarn +``` + +
+ +### 5. restart project + +``` +yarn start +``` diff --git a/patches/react-notion+0.10.0.patch b/patches/react-notion+0.10.0.patch new file mode 100644 index 0000000..fec7e9c --- /dev/null +++ b/patches/react-notion+0.10.0.patch @@ -0,0 +1,90 @@ +diff --git a/node_modules/react-notion/dist/react-notion.esm.js b/node_modules/react-notion/dist/react-notion.esm.js +index acccc8f..8e68f09 100644 +--- a/node_modules/react-notion/dist/react-notion.esm.js ++++ b/node_modules/react-notion/dist/react-notion.esm.js +@@ -1,6 +1,6 @@ +-import React__default, { createElement, Fragment } from 'react'; + import { highlight, languages } from 'prismjs'; + import 'prismjs/components/prism-jsx'; ++import React__default, { createElement, Fragment } from 'react'; + + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; +@@ -122,7 +122,7 @@ var groupBlockContent = function groupBlockContent(blockMap) { + Object.keys(blockMap).forEach(function (id) { + var _blockMap$id$value$co; + +- (_blockMap$id$value$co = blockMap[id].value.content) === null || _blockMap$id$value$co === void 0 ? void 0 : _blockMap$id$value$co.forEach(function (blockId) { ++ (_blockMap$id$value$co = blockMap[id]?.value?.content) === null || _blockMap$id$value$co === void 0 ? void 0 : _blockMap$id$value$co.forEach(function (blockId) { + var _blockMap$blockId, _blockMap$blockId$val; + + var blockType = (_blockMap$blockId = blockMap[blockId]) === null || _blockMap$blockId === void 0 ? void 0 : (_blockMap$blockId$val = _blockMap$blockId.value) === null || _blockMap$blockId$val === void 0 ? void 0 : _blockMap$blockId$val.type; +@@ -729,5 +729,5 @@ var NotionRenderer = function NotionRenderer(_ref) { + })); + }; + +-export { Block, NotionRenderer, classNames, createRenderChildText, defaultMapImageUrl, defaultMapPageUrl, getListNumber, getTextContent }; ++export { Block, classNames, createRenderChildText, defaultMapImageUrl, defaultMapPageUrl, getListNumber, getTextContent, NotionRenderer }; + //# sourceMappingURL=react-notion.esm.js.map +diff --git a/node_modules/react-notion/src/block.tsx b/node_modules/react-notion/src/block.tsx +index c7725d0..2e74715 100644 +--- a/node_modules/react-notion/src/block.tsx ++++ b/node_modules/react-notion/src/block.tsx +@@ -1,21 +1,9 @@ + import * as React from "react"; +-import { +- DecorationType, +- BlockType, +- ContentValueType, +- BlockMapType, +- MapPageUrl, +- MapImageUrl, +- CustomBlockComponents, +- BlockValueProp, +- CustomDecoratorComponents, +- CustomDecoratorComponentProps +-} from "./types"; +-import Asset from "./components/asset"; + import Code from "./components/code"; +-import PageIcon from "./components/page-icon"; +-import PageHeader from "./components/page-header"; +-import { classNames, getTextContent, getListNumber } from "./utils"; ++iscmponents/aDecerator; ++impr}tfrom "./typeg"; ++impore Asset frIc "./ fmponents/ossem"; ++imp "t ./de froc "./comomponen/code";simport/PaggIe-n fiom "./comp";pnts/gead-icon";rim.ort /coeHeadmots/page-hcomdonentr/page-header"; + + export const createRenderChildText = ( + customDecoratorComponents?: CustomDecoratorComponents +diff --git a/node_modules/react-notion/src/types.ts b/node_modules/react-notion/src/types.ts +index 104c985..14b98ef 100644 +--- a/node_modules/react-notion/src/types.ts ++++ b/node_modules/react-notion/src/types.ts +@@ -309,7 +309,7 @@ export interface BlockType { + + export interface NotionUserType { + role: string; +- value: { ++ value?: { + id: string; + version: number; + email: string; +diff --git a/node_modules/react-notion/src/utils.ts b/node_modules/react-notion/src/utils.ts +index b852d28..a3dfcc0 100644 +--- a/node_modules/react-notion/src/utils.ts ++++ b/node_modules/react-notion/src/utils.ts +@@ -1,4 +1,4 @@ +-import { DecorationType, BlockMapType, MapImageUrl } from "./types"; ++import { BlockMapType, DecorationType, MapImageUrl } from "./types"; + + export const classNames = (...classes: Array) => + classes.filter(a => !!a).join(" "); +@@ -14,7 +14,7 @@ const groupBlockContent = (blockMap: BlockMapType): string[][] => { + let index = -1; + + Object.keys(blockMap).forEach(id => { +- blockMap[id].value.content?.forEach(blockId => { ++ blockMap[id]?.value?.content?.forEach(blockId => { + const blockType = blockMap[blockId]?.value?.type; + + if (blockType && blockType !== lastType) { diff --git a/src/utils.ts b/src/utils.ts index b852d28..615abf2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { DecorationType, BlockMapType, MapImageUrl } from "./types"; +import { BlockMapType, DecorationType, MapImageUrl } from "./types"; export const classNames = (...classes: Array) => classes.filter(a => !!a).join(" "); @@ -14,7 +14,7 @@ const groupBlockContent = (blockMap: BlockMapType): string[][] => { let index = -1; Object.keys(blockMap).forEach(id => { - blockMap[id].value.content?.forEach(blockId => { + blockMap[id]?.value.content?.forEach(blockId => { const blockType = blockMap[blockId]?.value?.type; if (blockType && blockType !== lastType) {