diff --git a/components/NotionPageHeader.tsx b/components/NotionPageHeader.tsx index 64583055c6..e408c4d0ff 100644 --- a/components/NotionPageHeader.tsx +++ b/components/NotionPageHeader.tsx @@ -4,9 +4,17 @@ import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline' import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp' import { Header, Breadcrumbs, Search, useNotionContext } from 'react-notion-x' import * as types from 'notion-types' +import Image from 'next/image' import { useDarkMode } from 'lib/use-dark-mode' -import { navigationStyle, navigationLinks, isSearchEnabled } from 'lib/config' +import { + navigationStyle, + navigationLinks, + isSearchEnabled, + customHeaderLogo, + customHeaderLogoDark, + rootNotionPageId +} from 'lib/config' import styles from './styles.module.css' @@ -32,6 +40,48 @@ const ToggleThemeButton = () => { ) } +export const HeaderLogo: React.FC<{ + block: types.CollectionViewPageBlock | types.PageBlock +}> = ({ block }) => { + const { components, mapPageUrl } = useNotionContext() + + const { isDarkMode } = useDarkMode() + + const LinkWrapper = (props: { + currentPage: string + children: JSX.Element + }) => { + if (props.currentPage !== '/') { + return ( + + {props.children} + + ) + } + return
{props.children}
+ } + + return ( + + logo + + ) +} + export const NotionPageHeader: React.FC<{ block: types.CollectionViewPageBlock | types.PageBlock }> = ({ block }) => { @@ -44,7 +94,11 @@ export const NotionPageHeader: React.FC<{ return (
- + {customHeaderLogo ? ( + + ) : ( + + )}
{navigationLinks diff --git a/lib/config.ts b/lib/config.ts index cc9cbf2dd9..a33ed91f83 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -61,6 +61,16 @@ export const linkedin: string | null = getSiteConfig('linkedin', null) export const newsletter: string | null = getSiteConfig('newsletter', null) export const zhihu: string | null = getSiteConfig('zhihu', null) +// default logo values +export const customHeaderLogo: string | null = getSiteConfig( + 'customHeaderLogo', + null +) +export const customHeaderLogoDark: string | null = getSiteConfig( + 'customHeaderLogoDark', + null +) + // default notion values for site-wide consistency (optional; may be overridden on a per-page basis) export const defaultPageIcon: string | null = getSiteConfig( 'defaultPageIcon', diff --git a/lib/site-config.ts b/lib/site-config.ts index 61552d56a4..47dc74da56 100644 --- a/lib/site-config.ts +++ b/lib/site-config.ts @@ -17,6 +17,9 @@ export interface SiteConfig { youtube?: string zhihu?: string + customHeaderLogo?: string | null + customHeaderLogoDark?: string | null + defaultPageIcon?: string | null defaultPageCover?: string | null defaultPageCoverPosition?: number | null diff --git a/site.config.ts b/site.config.ts index f17107c6c1..26bd6876ac 100644 --- a/site.config.ts +++ b/site.config.ts @@ -23,6 +23,10 @@ export default siteConfig({ // newsletter: '#', // optional newsletter URL // youtube: '#', // optional youtube channel name or `channel/UCGbXXXXXXXXXXXXXXXXXXXXXX` + // Custom logo - this will replace the breadcrumbs - Feature requires navigationStyle: 'custom' + // customHeaderLogo: 'https://transitivebullsh.it/logo.png', + // customHeaderLogoDark: 'https://transitivebullsh.it/logo-dark.png', // optional + // default notion icon and cover images for site-wide consistency (optional) // page-specific values will override these site-wide defaults defaultPageIcon: null,