Skip to content

Modernization #629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.vscode/

.git/
.github/

node_modules/
*.log

11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:lts
WORKDIR /app

COPY package.json /app
COPY package-lock.json /app
RUN npm ci

COPY . /app
RUN npm run build

CMD ["npm", "run", "start"]
118 changes: 25 additions & 93 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
import * as React from 'react'

import { FaEnvelopeOpenText } from '@react-icons/all-files/fa/FaEnvelopeOpenText'
import { FaGithub } from '@react-icons/all-files/fa/FaGithub'
import { FaLinkedin } from '@react-icons/all-files/fa/FaLinkedin'
import { FaMastodon } from '@react-icons/all-files/fa/FaMastodon'
import { FaTwitter } from '@react-icons/all-files/fa/FaTwitter'
import { FaYoutube } from '@react-icons/all-files/fa/FaYoutube'
import { FaZhihu } from '@react-icons/all-files/fa/FaZhihu'
import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp'
import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline'
import { IoMoonSharp, IoSunnyOutline } from 'react-icons/io5'

import * as config from '@/lib/config'
import { useDarkMode } from '@/lib/use-dark-mode'

import { DarkModeContext } from '@/lib/use-dark-mode'
import { socialLinks } from './PageSocial'
import styles from './styles.module.css'
import { cs } from 'react-notion-x'

// TODO: merge the data and icons from PageSocial with the social links in Footer

export const FooterImpl: React.FC = () => {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()
const currentYear = new Date().getFullYear()
const [hasMounted, setHasMounted] = React.useState(false);
const { isDarkMode, toggleDarkMode } = React.useContext(DarkModeContext);
const currentYear = new Date().getFullYear();

const onToggleDarkMode = React.useCallback(
(e) => {
e.preventDefault()
toggleDarkMode()
},
[toggleDarkMode]
)
);

React.useEffect(() => {
setHasMounted(true)
}, [])
}, []);

return (
<footer className={styles.footer}>
Expand All @@ -52,89 +44,29 @@ export const FooterImpl: React.FC = () => {
)}
</div>

<div className={styles.social}>
{config.twitter && (
<a
className={styles.twitter}
href={`https://twitter.com/${config.twitter}`}
title={`Twitter @${config.twitter}`}
target='_blank'
rel='noopener noreferrer'
>
<FaTwitter />
</a>
)}

{config.mastodon && (
<a
className={styles.mastodon}
href={config.mastodon}
title={`Mastodon ${config.getMastodonHandle()}`}
rel='me'
>
<FaMastodon />
</a>
)}

{config.zhihu && (
<a
className={styles.zhihu}
href={`https://zhihu.com/people/${config.zhihu}`}
title={`Zhihu @${config.zhihu}`}
target='_blank'
rel='noopener noreferrer'
>
<FaZhihu />
</a>
)}
<style
dangerouslySetInnerHTML={{
__html: socialLinks.map((action) => (
`.social-link-footer-${action.name} {}
.social-link-footer-${action.name}:hover { color: ${action.color}; }
`
)).join('\n')
}}
/>

{config.github && (
<a
className={styles.github}
href={`https://github.com/${config.github}`}
title={`GitHub @${config.github}`}
target='_blank'
rel='noopener noreferrer'
>
<FaGithub />
</a>
)}

{config.linkedin && (
<a
className={styles.linkedin}
href={`https://www.linkedin.com/in/${config.linkedin}`}
title={`LinkedIn ${config.author}`}
target='_blank'
rel='noopener noreferrer'
>
<FaLinkedin />
</a>
)}

{config.newsletter && (
<div className={styles.social}>
{socialLinks.map((action) => (
<a
className={styles.newsletter}
href={`${config.newsletter}`}
title={`Newsletter ${config.author}`}
className={cs(styles[action.name], `social-link-footer-${action.name}`)}
href={action.href}
title={action.title}
target='_blank'
rel='noopener noreferrer'
>
<FaEnvelopeOpenText />
{action.icon({ size: 16 })}
</a>
)}
))}

{config.youtube && (
<a
className={styles.youtube}
href={`https://www.youtube.com/${config.youtube}`}
title={`YouTube ${config.author}`}
target='_blank'
rel='noopener noreferrer'
>
<FaYoutube />
</a>
)}
</div>
</footer>
)
Expand Down
86 changes: 44 additions & 42 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as types from '@/lib/types'
import { mapImageUrl } from '@/lib/map-image-url'
import { getCanonicalPageUrl, mapPageUrl } from '@/lib/map-page-url'
import { searchNotion } from '@/lib/search-notion'
import { useDarkMode } from '@/lib/use-dark-mode'
import { DarkModeContext, useDarkMode } from '@/lib/use-dark-mode'

import { Footer } from './Footer'
import { GitHubShareButton } from './GitHubShareButton'
Expand Down Expand Up @@ -172,7 +172,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
// lite mode is for oembed
const isLiteMode = lite === 'true'

const { isDarkMode } = useDarkMode()
const { isDarkMode, toggleDarkMode } = useDarkMode()

const siteMapPageUrl = React.useMemo(() => {
const params: any = {}
Expand Down Expand Up @@ -233,8 +233,8 @@ export const NotionPage: React.FC<types.PageProps> = ({

const socialImage = mapImageUrl(
getPageProperty<string>('Social Image', block, recordMap) ||
(block as PageBlock).format?.page_cover ||
config.defaultPageCover,
(block as PageBlock).format?.page_cover ||
config.defaultPageCover,
block
)

Expand All @@ -244,44 +244,46 @@ export const NotionPage: React.FC<types.PageProps> = ({

return (
<>
<PageHead
pageId={pageId}
site={site}
title={title}
description={socialDescription}
image={socialImage}
url={canonicalPageUrl}
/>

{isLiteMode && <BodyClassName className='notion-lite' />}
{isDarkMode && <BodyClassName className='dark-mode' />}

<NotionRenderer
bodyClassName={cs(
styles.notion,
pageId === site.rootNotionPageId && 'index-page'
)}
darkMode={isDarkMode}
components={components}
recordMap={recordMap}
rootPageId={site.rootNotionPageId}
rootDomain={site.domain}
fullPage={!isLiteMode}
previewImages={!!recordMap.preview_images}
showCollectionViewDropdown={false}
showTableOfContents={showTableOfContents}
minTableOfContentsItems={minTableOfContentsItems}
defaultPageIcon={config.defaultPageIcon}
defaultPageCover={config.defaultPageCover}
defaultPageCoverPosition={config.defaultPageCoverPosition}
mapPageUrl={siteMapPageUrl}
mapImageUrl={mapImageUrl}
searchNotion={config.isSearchEnabled ? searchNotion : null}
pageAside={pageAside}
footer={footer}
/>

<GitHubShareButton />
<DarkModeContext.Provider value={{ isDarkMode, toggleDarkMode }}>
<PageHead
pageId={pageId}
site={site}
title={title}
description={socialDescription}
image={socialImage}
url={canonicalPageUrl}
/>

{isLiteMode && <BodyClassName className='notion-lite' />}
{isDarkMode && <BodyClassName className='dark-mode' />}

<NotionRenderer
bodyClassName={cs(
styles.notion,
pageId === site.rootNotionPageId && 'index-page'
)}
darkMode={isDarkMode}
components={components}
recordMap={recordMap}
rootPageId={site.rootNotionPageId}
rootDomain={site.domain}
fullPage={!isLiteMode}
previewImages={!!recordMap.preview_images}
showCollectionViewDropdown={false}
showTableOfContents={showTableOfContents}
minTableOfContentsItems={minTableOfContentsItems}
defaultPageIcon={config.defaultPageIcon}
defaultPageCover={config.defaultPageCover}
defaultPageCoverPosition={config.defaultPageCoverPosition}
mapPageUrl={siteMapPageUrl}
mapImageUrl={mapImageUrl}
searchNotion={config.isSearchEnabled ? searchNotion : null}
pageAside={pageAside}
footer={footer}
/>

{config.isGithubShareButtonEnabled && <GitHubShareButton />}
</DarkModeContext.Provider>
</>
)
}
9 changes: 4 additions & 5 deletions components/NotionPageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import * as React from 'react'

import * as types from 'notion-types'
import { IoMoonSharp } from '@react-icons/all-files/io5/IoMoonSharp'
import { IoSunnyOutline } from '@react-icons/all-files/io5/IoSunnyOutline'
import cs from 'classnames'
import * as types from 'notion-types'
import { IoMoonSharp, IoSunnyOutline } from 'react-icons/io5'
import { Breadcrumbs, Header, Search, useNotionContext } from 'react-notion-x'

import { isSearchEnabled, navigationLinks, navigationStyle } from '@/lib/config'
import { useDarkMode } from '@/lib/use-dark-mode'
import { DarkModeContext } from '@/lib/use-dark-mode'

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

const ToggleThemeButton = () => {
const [hasMounted, setHasMounted] = React.useState(false)
const { isDarkMode, toggleDarkMode } = useDarkMode()
const { isDarkMode, toggleDarkMode } = React.useContext(DarkModeContext)

React.useEffect(() => {
setHasMounted(true)
Expand Down
4 changes: 2 additions & 2 deletions components/PageActions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'

import { AiOutlineRetweet } from '@react-icons/all-files/ai/AiOutlineRetweet'
import { IoHeartOutline } from '@react-icons/all-files/io5/IoHeartOutline'
import { AiOutlineRetweet } from 'react-icons/ai'
import { IoHeartOutline } from 'react-icons/io5'

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

Expand Down
Loading