Skip to content

Commit 62f82e2

Browse files
committed
update: optimize site code
1 parent 9dd8ba4 commit 62f82e2

File tree

7 files changed

+98
-60
lines changed

7 files changed

+98
-60
lines changed

components/Footer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ export const FooterImpl: React.FC = () => {
3434

3535
return (
3636
<footer className={styles.footer}>
37-
<div className={styles.copyright}>Copyright 2022 {config.author}</div>
37+
<div className={styles.copyright}>
38+
Copyright {new Date().getFullYear()} {config.author}
39+
</div>
3840

3941
<div className={styles.settings}>
4042
{hasMounted && (

components/NotionPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ import { PageAside } from './PageAside'
2828
import { PageHead } from './PageHead'
2929
import styles from './styles.module.css'
3030

31-
3231
// -----------------------------------------------------------------------------
3332
// dynamic imports for optional components
3433
// -----------------------------------------------------------------------------
3534

3635
const Code = dynamic(() =>
3736
import('react-notion-x/build/third-party/code').then(async (m) => {
3837
// add / remove any prism syntaxes here
39-
await Promise.all([
38+
await Promise.allSettled([
4039
import('prismjs/components/prism-markup-templating.js'),
4140
import('prismjs/components/prism-markup.js'),
4241
import('prismjs/components/prism-bash.js'),

components/PageHead.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ export const PageHead: React.FC<
2626
<meta httpEquiv='Content-Type' content='text/html; charset=utf-8' />
2727
<meta
2828
name='viewport'
29-
content='width=device-width, initial-scale=1, shrink-to-fit=no'
29+
content='width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover'
3030
/>
31+
32+
<meta name='apple-mobile-web-app-capable' content='yes' />
33+
<meta name='apple-mobile-web-app-status-bar-style' content='black' />
3134
<meta
3235
name='theme-color'
3336
media='(prefers-color-scheme: light)'

components/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
caret-color: rgb(55, 53, 47);
2222
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica,
2323
'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';
24+
background-color: var(--bg-color);
2425
}
2526

2627
.loadingIcon {

lib/get-site-map.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAllPagesInSpace, uuidToId } from 'notion-utils'
1+
import { getAllPagesInSpace, uuidToId, getPageProperty } from 'notion-utils'
22
import pMemoize from 'p-memoize'
33

44
import * as config from './config'
@@ -47,6 +47,13 @@ async function getAllPagesImpl(
4747
throw new Error(`Error loading page "${pageId}"`)
4848
}
4949

50+
const block = recordMap.block[pageId]?.value
51+
if (
52+
!(getPageProperty<boolean | null>('Public', block, recordMap) ?? true)
53+
) {
54+
return map
55+
}
56+
5057
const canonicalPageId = getCanonicalPageId(pageId, recordMap, {
5158
uuid
5259
})

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"fathom-client": "^3.4.1",
3737
"got": "^12.0.3",
3838
"isomorphic-unfetch": "^3.1.0",
39-
"lqip-modern": "^1.2.0",
40-
"next": "^12.3.1",
39+
"lqip-modern": "^2.0.0",
40+
"next": "12",
4141
"notion-client": "^6.13.11",
4242
"notion-types": "^6.13.4",
4343
"notion-utils": "^6.13.4",
@@ -49,7 +49,7 @@
4949
"react-dom": "^18.2.0",
5050
"react-notion-x": "^6.15.3",
5151
"react-tweet-embed": "^2.0.0",
52-
"react-use": "^17.3.2",
52+
"react-use": "^17.4.0",
5353
"rss": "^1.2.2"
5454
},
5555
"devDependencies": {

styles/notion.css

Lines changed: 78 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
margin-bottom: 1em;
3939
}
4040

41-
.notion-asset-wrapper-video>div,
41+
.notion-asset-wrapper-video > div,
4242
.notion-asset-wrapper-video video {
4343
width: 100% !important;
4444
}
@@ -102,7 +102,6 @@
102102

103103
/* only target safari */
104104
@media screen and (-webkit-min-device-pixel-ratio: 0) {
105-
106105
_::-webkit-full-page-media,
107106
_:future,
108107
:root,
@@ -185,7 +184,6 @@
185184
}
186185

187186
@media only screen and (max-width: 1200px) {
188-
189187
.notion-page-cover-wrapper,
190188
.notion-page-cover-wrapper span,
191189
.notion-page-cover-wrapper img {
@@ -235,83 +233,101 @@
235233
background-color: none;
236234

237235
/* light yellow */
238-
background-image: linear-gradient(90deg,
239-
var(--bg-color),
240-
#fdeed2 10.5%,
241-
#fde4b5 85.29%,
242-
var(--bg-color));
236+
background-image: linear-gradient(
237+
90deg,
238+
var(--bg-color),
239+
#fdeed2 10.5%,
240+
#fde4b5 85.29%,
241+
var(--bg-color)
242+
);
243243
}
244244

245245
.notion-purple_background {
246246
/* light pink */
247-
background-image: linear-gradient(90deg,
248-
var(--bg-color),
249-
#e4d3fd 10.5%,
250-
#d3b6ff 85.29%,
251-
var(--bg-color));
247+
background-image: linear-gradient(
248+
90deg,
249+
var(--bg-color),
250+
#e4d3fd 10.5%,
251+
#d3b6ff 85.29%,
252+
var(--bg-color)
253+
);
252254
}
253255

254256
.notion-pink_background {
255257
/* light pink */
256-
background-image: linear-gradient(90deg,
257-
var(--bg-color),
258-
#ffd2e7 10.5%,
259-
#ffadd3 85.29%,
260-
var(--bg-color));
258+
background-image: linear-gradient(
259+
90deg,
260+
var(--bg-color),
261+
#ffd2e7 10.5%,
262+
#ffadd3 85.29%,
263+
var(--bg-color)
264+
);
261265
}
262266

263267
.notion-gray_background {
264268
/* light blue */
265-
background-image: linear-gradient(90deg,
266-
var(--bg-color),
267-
#cfcfcf 10.5%,
268-
#a0a0a0 85.29%,
269-
var(--bg-color));
269+
background-image: linear-gradient(
270+
90deg,
271+
var(--bg-color),
272+
#cfcfcf 10.5%,
273+
#a0a0a0 85.29%,
274+
var(--bg-color)
275+
);
270276
}
271277

272278
.notion-blue_background {
273279
/* light blue */
274-
background-image: linear-gradient(90deg,
275-
var(--bg-color),
276-
#d9eafd 10.5%,
277-
#b3d6ff 85.29%,
278-
var(--bg-color));
280+
background-image: linear-gradient(
281+
90deg,
282+
var(--bg-color),
283+
#d9eafd 10.5%,
284+
#b3d6ff 85.29%,
285+
var(--bg-color)
286+
);
279287
}
280288

281289
.notion-red_background {
282290
/* light red */
283-
background-image: linear-gradient(90deg,
284-
var(--bg-color),
285-
#ffc3c3 10.5%,
286-
#fba6a3 85.29%,
287-
var(--bg-color));
291+
background-image: linear-gradient(
292+
90deg,
293+
var(--bg-color),
294+
#ffc3c3 10.5%,
295+
#fba6a3 85.29%,
296+
var(--bg-color)
297+
);
288298
}
289299

290300
.notion-orange_background {
291301
/* light red */
292-
background-image: linear-gradient(90deg,
293-
var(--bg-color),
294-
#ffe6b1 10.5%,
295-
#ffd09b 85.29%,
296-
var(--bg-color));
302+
background-image: linear-gradient(
303+
90deg,
304+
var(--bg-color),
305+
#ffe6b1 10.5%,
306+
#ffd09b 85.29%,
307+
var(--bg-color)
308+
);
297309
}
298310

299311
.notion-teal_background {
300312
/* light green */
301-
background-image: linear-gradient(90deg,
302-
var(--bg-color),
303-
#d4eabc 10.5%,
304-
#d2eabc 85.29%,
305-
var(--bg-color));
313+
background-image: linear-gradient(
314+
90deg,
315+
var(--bg-color),
316+
#d4eabc 10.5%,
317+
#d2eabc 85.29%,
318+
var(--bg-color)
319+
);
306320
}
307321

308322
.notion-brown_background {
309323
/* dark blue */
310-
background-image: linear-gradient(90deg,
311-
var(--bg-color),
312-
#cab7ae 10.5%,
313-
#b1998d 85.29%,
314-
var(--bg-color));
324+
background-image: linear-gradient(
325+
90deg,
326+
var(--bg-color),
327+
#cab7ae 10.5%,
328+
#b1998d 85.29%,
329+
var(--bg-color)
330+
);
315331
}
316332

317333
.dark-mode .notion-red_background,
@@ -345,10 +361,16 @@
345361
backdrop-filter: saturate(180%) blur(16px);
346362
}
347363

364+
.notion-header .notion-nav-header {
365+
max-width: 1100px;
366+
margin: 0 auto;
367+
overflow-x: auto;
368+
}
369+
348370
.dark-mode .notion-header {
349371
background: transparent;
350372
box-shadow: inset 0 -1px 0 0 rgba(0, 0, 0, 0.1);
351-
backdrop-filter: saturate(180%) blur(8px);
373+
backdrop-filter: saturate(180%) blur(20px);
352374
}
353375

354376
.notion-bookmark:hover {
@@ -399,19 +421,23 @@
399421
::-webkit-scrollbar {
400422
width: 5px;
401423
height: 5px;
402-
background-color: #F5F5F5;
424+
background-color: #f5f5f5;
403425
background-color: var(--bg-color-1);
404426
}
405427

406428
::-webkit-scrollbar-thumb {
407429
border-radius: 10px;
408-
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
430+
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
409431
background-color: #555;
410432
border-radius: 10px;
411-
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
433+
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
412434
background-color: var(--fg-color-1);
413435
}
414436

415437
::-webkit-scrollbar-track {
416438
background-color: var(--bg-color);
417439
}
440+
441+
.notion-equation.notion-equation-block {
442+
align-items: center;
443+
}

0 commit comments

Comments
 (0)