1
1
import * as React from 'react'
2
-
3
- import * as types from 'notion-types'
4
- import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp'
5
- import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline'
6
2
import cs from 'classnames'
7
- import { Breadcrumbs , Header , Search , useNotionContext } from 'react-notion-x'
3
+ import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline'
4
+ import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp'
5
+ import { Header , Breadcrumbs , Search , useNotionContext } from 'react-notion-x'
6
+ import * as types from 'notion-types'
7
+ import Image from 'next/image'
8
8
9
- import { isSearchEnabled , navigationLinks , navigationStyle } from '@/lib/config'
10
- import { useDarkMode } from '@/lib/use-dark-mode'
9
+ import { useDarkMode } from 'lib/use-dark-mode'
10
+ import {
11
+ navigationStyle ,
12
+ navigationLinks ,
13
+ isSearchEnabled ,
14
+ customHeaderLogo ,
15
+ customHeaderLogoDark ,
16
+ rootNotionPageId
17
+ } from 'lib/config'
11
18
12
19
import styles from './styles.module.css'
13
20
@@ -33,6 +40,48 @@ const ToggleThemeButton = () => {
33
40
)
34
41
}
35
42
43
+ export const HeaderLogo : React . FC < {
44
+ block : types . CollectionViewPageBlock | types . PageBlock
45
+ } > = ( { block } ) => {
46
+ const { components, mapPageUrl } = useNotionContext ( )
47
+
48
+ const { isDarkMode } = useDarkMode ( )
49
+
50
+ const LinkWrapper = ( props : {
51
+ currentPage : string
52
+ children : JSX . Element
53
+ } ) => {
54
+ if ( props . currentPage !== '/' ) {
55
+ return (
56
+ < components . PageLink
57
+ href = { mapPageUrl ( rootNotionPageId ) }
58
+ key = { 0 }
59
+ className = { cs ( styles . navLink , 'breadcrumb' , 'button' ) }
60
+ >
61
+ { props . children }
62
+ </ components . PageLink >
63
+ )
64
+ }
65
+ return < div style = { { padding : 12 , display : 'flex' } } > { props . children } </ div >
66
+ }
67
+
68
+ return (
69
+ < LinkWrapper currentPage = { mapPageUrl ( block . id ) } >
70
+ < Image
71
+ src = {
72
+ isDarkMode && customHeaderLogoDark
73
+ ? customHeaderLogoDark
74
+ : customHeaderLogo
75
+ }
76
+ width = '100%'
77
+ height = '100%'
78
+ objectFit = 'contain'
79
+ alt = 'logo'
80
+ />
81
+ </ LinkWrapper >
82
+ )
83
+ }
84
+
36
85
export const NotionPageHeader : React . FC < {
37
86
block : types . CollectionViewPageBlock | types . PageBlock
38
87
} > = ( { block } ) => {
@@ -45,7 +94,11 @@ export const NotionPageHeader: React.FC<{
45
94
return (
46
95
< header className = 'notion-header' >
47
96
< div className = 'notion-nav-header' >
48
- < Breadcrumbs block = { block } rootOnly = { true } />
97
+ { customHeaderLogo ? (
98
+ < HeaderLogo block = { block } />
99
+ ) : (
100
+ < Breadcrumbs block = { block } rootOnly = { true } />
101
+ ) }
49
102
50
103
< div className = 'notion-nav-header-rhs breadcrumbs' >
51
104
{ navigationLinks
0 commit comments