Skip to content

Commit 5417bb9

Browse files
feat: lots of refactors and improvements
1 parent c0904c8 commit 5417bb9

27 files changed

+841
-3073
lines changed

.env.example

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
# @see https://github.com/rolodato/dotenv-safe for more details.
88
# ------------------------------------------------------------------------------
99

10-
# Optional (for preview image support)
11-
#GOOGLE_APPLICATION_CREDENTIALS=
12-
13-
# Optional (for preview image support)
14-
#GCLOUD_PROJECT=
15-
16-
# Optional (for preview image support)
17-
#FIREBASE_COLLECTION_IMAGES=
18-
1910
# Optional (for fathom analytics)
2011
#NEXT_PUBLIC_FATHOM_ID=
2112

.eslintrc

Lines changed: 0 additions & 38 deletions
This file was deleted.

.eslintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint", "react", "react-hooks"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:react/recommended",
9+
"plugin:react-hooks/recommended",
10+
"prettier"
11+
],
12+
"settings": {
13+
"react": {
14+
"version": "detect"
15+
}
16+
},
17+
"env": {
18+
"browser": true,
19+
"node": true
20+
},
21+
"rules": {
22+
"@typescript-eslint/no-explicit-any": 0,
23+
"@typescript-eslint/no-non-null-assertion": 0,
24+
"@typescript-eslint/no-unused-vars": 2,
25+
"react/prop-types": 0
26+
}
27+
}

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

api/create-preview-image.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Footer: React.FC<{
2626

2727
return (
2828
<footer className={styles.footer}>
29-
<div className={styles.copyright}>Copyright 2021 {config.author}</div>
29+
<div className={styles.copyright}>Copyright 2022 {config.author}</div>
3030

3131
{hasMounted ? (
3232
<div className={styles.settings}>

components/NotionPage.tsx

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react'
2+
import Image from 'next/image'
23
import Head from 'next/head'
34
import Link from 'next/link'
45
import dynamic from 'next/dynamic'
@@ -33,10 +34,13 @@ import { PageActions } from './PageActions'
3334
import { Footer } from './Footer'
3435
import { PageSocial } from './PageSocial'
3536
import { GitHubShareButton } from './GitHubShareButton'
36-
import { ReactUtterances } from './ReactUtterances'
3737

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

40+
// -----------------------------------------------------------------------------
41+
// dynamic imports for optional components
42+
// -----------------------------------------------------------------------------
43+
4044
// const Code = dynamic(() =>
4145
// import('react-notion-x').then((notion) => notion.Code)
4246
// )
@@ -51,21 +55,15 @@ import styles from './styles.module.css'
5155
// ssr: false
5256
// }
5357
// )
54-
55-
// TODO: PDF support via "react-pdf" package has numerous troubles building
56-
// with next.js
58+
//
5759
// const Pdf = dynamic(
58-
// () => import('react-notion-x').then((notion) => notion.Pdf),
60+
// () => import('react-notion-x').then((notion) => (notion as any).Pdf),
5961
// { ssr: false }
6062
// )
61-
62-
const Equation = dynamic(() =>
63-
import('react-notion-x').then((notion) => notion.Equation)
64-
)
65-
66-
// we're now using a much lighter-weight tweet renderer react-static-tweets
67-
// instead of the official iframe-based embed widget from twitter
68-
// const Tweet = dynamic(() => import('react-tweet-embed'))
63+
//
64+
// const Equation = dynamic(() =>
65+
// import('react-notion-x').then((notion) => notion.Equation)
66+
// )
6967

7068
const Modal = dynamic(
7169
() => import('react-notion-x').then((notion) => notion.Modal),
@@ -139,22 +137,10 @@ export const NotionPage: React.FC<types.PageProps> = ({
139137
const socialDescription =
140138
getPageDescription(block, recordMap) ?? config.description
141139

142-
let comments: React.ReactNode = null
143140
let pageAside: React.ReactChild = null
144141

145142
// only display comments and page actions on blog post pages
146143
if (isBlogPost) {
147-
if (config.utterancesGitHubRepo) {
148-
comments = (
149-
<ReactUtterances
150-
repo={config.utterancesGitHubRepo}
151-
issueMap='issue-term'
152-
issueTerm='title'
153-
theme={darkMode.value ? 'photon-dark' : 'github-light'}
154-
/>
155-
)
156-
}
157-
158144
const tweet = getPageTweet(block, recordMap)
159145
if (tweet) {
160146
pageAside = <PageActions tweet={tweet} />
@@ -249,15 +235,43 @@ export const NotionPage: React.FC<types.PageProps> = ({
249235
<a {...props} />
250236
</Link>
251237
),
238+
image: ({
239+
src,
240+
alt,
241+
242+
width,
243+
height,
244+
245+
className,
246+
style,
247+
248+
...rest
249+
}) => {
250+
const layout = width && height ? 'intrinsic' : 'fill'
251+
252+
return (
253+
<Image
254+
{...rest}
255+
className={className}
256+
src={src}
257+
alt={alt}
258+
width={layout === 'intrinsic' && width}
259+
height={layout === 'intrinsic' && height}
260+
objectFit={style?.objectFit}
261+
objectPosition={style?.objectPosition}
262+
layout={layout}
263+
/>
264+
)
265+
},
252266
code: Code,
253267
collection: Collection,
254268
collectionRow: CollectionRow,
255269
tweet: Tweet,
256-
modal: Modal,
257-
equation: Equation
270+
modal: Modal
258271
}}
259272
recordMap={recordMap}
260273
rootPageId={site.rootNotionPageId}
274+
rootDomain={site.domain}
261275
fullPage={!isLiteMode}
262276
darkMode={darkMode.value}
263277
previewImages={site.previewImages !== false}
@@ -270,7 +284,6 @@ export const NotionPage: React.FC<types.PageProps> = ({
270284
mapPageUrl={siteMapPageUrl}
271285
mapImageUrl={mapNotionImageUrl}
272286
searchNotion={searchNotion}
273-
pageFooter={comments}
274287
pageAside={pageAside}
275288
footer={
276289
<Footer

components/Page404.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export const Page404: React.FC<types.PageProps> = ({ site, pageId, error }) => {
2828
) : (
2929
pageId && (
3030
<p>
31-
Make sure that Notion page "{pageId}" is publicly accessible.
31+
Make sure that Notion page &quot;{pageId}&quot; is publicly
32+
accessible.
3233
</p>
3334
)
3435
)}

0 commit comments

Comments
 (0)