import * as React from 'react'
import { Block, Decoration } from 'notion-types'
import { getBlockTitle } from 'notion-utils'
import { cs } from '../utils'
import { useNotionContext } from '../context'
import { Text } from './text'
import { PageIcon } from './page-icon'
export const PageTitleImpl: React.FC<{
block: Block
className?: string
defaultIcon?: string
}> = ({ block, className, defaultIcon, ...rest }) => {
const { recordMap } = useNotionContext()
if (!block) return null
if (
block.type === 'collection_view_page' ||
block.type === 'collection_view'
) {
const title = getBlockTitle(block, recordMap)
if (!title) {
return null
}
const titleDecoration: Decoration[] = [[title]]
return (
)
}
if (!block.properties?.title) {
return null
}
return (
)
}
export const PageTitle = React.memo(PageTitleImpl)