Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1e58a97

Browse files
Merge pull request #674 from NotionX/wustep/improvements
2 parents 6468b7a + d4d4774 commit 1e58a97

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

‎contributing.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Suggestions and pull requests are highly encouraged. Have a look at the [open is
66

77
To develop the project locally, you'll need a recent version of Node.js and `pnpm` installed globally.
88

9-
To get started, clone the repo and run `pnpm` from the root directory:
9+
To get started, clone the repo and run `pnpm install` from the root directory:
1010

1111
```bash
1212
git clone https://github.com/NotionX/react-notion-x.git
1313
cd react-notion-x
14-
pnpm
14+
pnpm install
1515
```
1616

1717
This will install dependencies and link all of the local packages together using `lerna`. This includes the example projects which will now point to the local version of your packages.

‎examples/full/pages/[pageId].tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const getStaticProps = async (context: any) => {
1616
const recordMap = await notion.getPage(pageId)
1717

1818
// NOTE: this isn't necessary; trying to reduce my vercel bill
19-
if (recordMap.block[0]?.value?.space_id !== rootNotionSpaceId) {
19+
const blockIds = Object.keys(recordMap.block)
20+
const firstBlock = blockIds.length > 0 ? recordMap.block[blockIds[0]!] : null
21+
if (rootNotionSpaceId && firstBlock?.value?.space_id !== rootNotionSpaceId) {
2022
return {
2123
notFound: true
2224
}

‎examples/minimal/pages/[pageId].tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const getStaticProps = async (context: any) => {
99
const recordMap = await notion.getPage(pageId)
1010

1111
// NOTE: this isn't necessary; trying to reduce my vercel bill
12-
if (recordMap.block[0]?.value?.space_id !== rootNotionSpaceId) {
12+
const blockIds = Object.keys(recordMap.block)
13+
const firstBlock = blockIds.length > 0 ? recordMap.block[blockIds[0]!] : null
14+
if (rootNotionSpaceId && firstBlock?.value?.space_id !== rootNotionSpaceId) {
1315
return {
1416
notFound: true
1517
}

‎packages/notion-utils/src/map-image-url.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { type Block } from 'notion-types'
22

3+
// eslint-disable-next-line security/detect-unsafe-regex
4+
const GIF_REGEXP = /(?:https?:\/\/)?[^\s]+\.gif(?=$|\?|#)/
5+
36
export const defaultMapImageUrl = (
47
url: string | undefined,
58
block: Block
@@ -12,6 +15,10 @@ export const defaultMapImageUrl = (
1215
return url
1316
}
1417

18+
if (GIF_REGEXP.test(url)) {
19+
return url
20+
}
21+
1522
// more recent versions of notion don't proxy unsplash images
1623
if (url.startsWith('https://images.unsplash.com')) {
1724
return url

‎packages/react-notion-x/src/components/asset.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,9 @@ export function Asset({
274274
}
275275
}
276276
} else if (block.type === 'image') {
277-
// console.log('image', block)
278277
// TODO: kind of a hack for now. New file.notion.so images aren't signed correctly
279-
if (source.includes('file.notion.so')) {
278+
// Gifs need to use their original file URLs and not the source prop (see #663)
279+
if (!source.includes('.gif') && source.includes('file.notion.so')) {
280280
source = block.properties?.source?.[0]?.[0]
281281
}
282282
const src = mapImageUrl(source, block as Block)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /