Skip to content

Commit

Permalink
feat: halloween shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Oct 31, 2024
1 parent 47fb259 commit 3aa300c
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 54 deletions.
14 changes: 7 additions & 7 deletions examples/full/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type * as React from 'react'

import { LoadingIcon } from './LoadingIcon'
import styles from './styles.module.css'

export const Loading: React.FC = () => (
<div className={styles.container}>
<LoadingIcon />
</div>
)
export function Loading() {
return (
<div className={styles.container}>
<LoadingIcon />
</div>
)
}
3 changes: 1 addition & 2 deletions examples/full/components/LoadingIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import cs from 'classnames'
import * as React from 'react'

import styles from './styles.module.css'

export const LoadingIcon = (props: any) => {
export function LoadingIcon(props: any) {
const { className, ...rest } = props
return (
<svg
Expand Down
7 changes: 3 additions & 4 deletions examples/full/components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Link from 'next/link'
import { useRouter } from 'next/router'
import { type ExtendedRecordMap } from 'notion-types'
import { getPageTitle } from 'notion-utils'
import * as React from 'react'
import { NotionRenderer } from 'react-notion-x'
import TweetEmbed from 'react-tweet-embed'

Expand Down Expand Up @@ -75,11 +74,11 @@ const Modal = dynamic(
}
)

const Tweet = ({ id }: { id: string }) => {
function Tweet({ id }: { id: string }) {
return <TweetEmbed tweetId={id} />
}

export const NotionPage = ({
export function NotionPage({
recordMap,
previewImagesEnabled,
rootPageId,
Expand All @@ -89,7 +88,7 @@ export const NotionPage = ({
previewImagesEnabled?: boolean
rootPageId?: string
rootDomain?: string
}) => {
}) {
const router = useRouter()

if (router.isFallback) {
Expand Down
6 changes: 5 additions & 1 deletion examples/full/lib/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
}

export async function search(params: SearchParams): Promise<SearchResults> {
return notion.search(params)
if ('search' in notion) {
return notion.search(params)
} else {
throw new Error('Notion API does not support search')
}
}
3 changes: 2 additions & 1 deletion examples/full/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
"next": "^15.0.2",
"notion-client": "workspace:*",
"notion-compat": "workspace:*",
"notion-utils": "workspace:*",
"notion-types": "workspace:*",
"notion-utils": "workspace:*",
"p-map": "^7.0.2",
"p-memoize": "^7.1.1",
"prismjs": "^1.27.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-notion-x": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion examples/full/pages/[pageId].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type ExtendedRecordMap } from 'notion-types'
import { getAllPagesInSpace } from 'notion-utils'
import * as React from 'react'
import { defaultMapPageUrl } from 'react-notion-x'

import { NotionPage } from '../components/NotionPage'
Expand Down
4 changes: 1 addition & 3 deletions examples/full/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import 'katex/dist/katex.min.css'
import 'prismjs/themes/prism-tomorrow.css'
// core styles shared by all of react-notion-x (required)
import 'react-notion-x/src/styles.css'
// force push
// app styles
import '../styles/globals.css'

import * as React from 'react'

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}
Expand Down
1 change: 0 additions & 1 deletion examples/full/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Document, { Head, Html, Main, NextScript } from 'next/document'
import * as React from 'react'

export default class MyDocument extends Document {
render() {
Expand Down
1 change: 0 additions & 1 deletion examples/full/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type ExtendedRecordMap } from 'notion-types'
import * as React from 'react'

import { NotionPage } from '../components/NotionPage'
import {
Expand Down
9 changes: 4 additions & 5 deletions examples/full/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{
"compilerOptions": {
"target": "es2016",
"lib": ["dom", "esnext"],
"allowJs": false,
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
Expand Down
5 changes: 2 additions & 3 deletions examples/minimal/components/NotionPage.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import Head from 'next/head'
import { type ExtendedRecordMap } from 'notion-types'
import { getPageTitle } from 'notion-utils'
import * as React from 'react'
import { NotionRenderer } from 'react-notion-x'

export const NotionPage = ({
export function NotionPage({
recordMap,
rootPageId
}: {
recordMap: ExtendedRecordMap
rootPageId?: string
}) => {
}) {
if (!recordMap) {
return null
}
Expand Down
1 change: 0 additions & 1 deletion examples/minimal/pages/[pageId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type ExtendedRecordMap } from 'notion-types'
import * as React from 'react'

import { NotionPage } from '../components/NotionPage'
import { rootNotionPageId } from '../lib/config'
Expand Down
2 changes: 0 additions & 2 deletions examples/minimal/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import 'react-notion-x/src/styles.css'
import '../styles/globals.css'

import * as React from 'react'

// used for code syntax highlighting (optional)
// import 'prismjs/themes/prism-tomorrow.css'

Expand Down
1 change: 0 additions & 1 deletion examples/minimal/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Document, { Head, Html, Main, NextScript } from 'next/document'
import * as React from 'react'

export default class MyDocument extends Document {
render() {
Expand Down
1 change: 0 additions & 1 deletion examples/minimal/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type ExtendedRecordMap } from 'notion-types'
import * as React from 'react'

import { NotionPage } from '../components/NotionPage'
import { rootNotionPageId } from '../lib/config'
Expand Down
16 changes: 0 additions & 16 deletions packages/react-notion-x/src/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ const tocIndentLevelCache: {
const pageCoverStyleCache: Record<string, object> = {}

export function Block(props: BlockProps) {
console.log('Block', {
id: props.block.id,
type: props.block.type,
level: props.level
})

const ctx = useNotionContext()
const {
components,
Expand Down Expand Up @@ -154,16 +148,6 @@ export function Block(props: BlockProps) {
const hasAside = !!((hasToc || pageAside) && !page_full_width)
const hasPageCover = !!(pageCover || page_cover)

console.log({
disableHeader,
header,
pageCover,
pageHeader,
pageFooter,
footer,
components
})

return (
<div
className={cs(
Expand Down
1 change: 0 additions & 1 deletion packages/react-notion-x/src/components/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ export function Text({
const externalObjectInstance = recordMap.block[blockId]
?.value as ExternalObjectInstance

console.log('eoi', blockId, externalObjectInstance)
return <EOI block={externalObjectInstance} inline={true} />
}

Expand Down
3 changes: 0 additions & 3 deletions packages/react-notion-x/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ export function NotionContextProvider({
[mapImageUrl, mapPageUrl, wrappedThemeComponents, rootPageId, rest]
)

console.log('NotionContextProvider', { value })
console.log({ rest, defaultComponents, wrappedThemeComponents })

return <ctx.Provider value={value}>{children}</ctx.Provider>
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-notion-x/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2251,6 +2251,8 @@ svg.notion-page-icon {

.lazy-image-wrapper img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
Expand Down
3 changes: 3 additions & 0 deletions packages/react-notion-x/src/third-party/code.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line import/no-duplicates
import 'prismjs'
import 'prismjs/components/prism-clike.min.js'
import 'prismjs/components/prism-css-extras.min.js'
import 'prismjs/components/prism-css.min.js'
Expand All @@ -11,6 +13,7 @@ import 'prismjs/components/prism-typescript.min.js'
import copyToClipboard from 'clipboard-copy'
import { type CodeBlock } from 'notion-types'
import { getBlockTitle } from 'notion-utils'
// eslint-disable-next-line import/no-duplicates, no-duplicate-imports
import { highlightElement } from 'prismjs'
import * as React from 'react'

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3aa300c

Please sign in to comment.