Skip to content

Commit a24bb31

Browse files
committed
2 parents 001bacb + 61bdfef commit a24bb31

File tree

9 files changed

+70
-26
lines changed

9 files changed

+70
-26
lines changed

components/PrismMac.js

+38-11
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ const PrismMac = () => {
4343
loadExternalResource('/css/prism-mac-style.css', 'css')
4444
}
4545
// 加载prism样式
46-
loadPrismThemeCSS(isDarkMode, prismThemeSwitch, prismThemeDarkPath, prismThemeLightPath, prismThemePrefixPath)
46+
loadPrismThemeCSS(
47+
isDarkMode,
48+
prismThemeSwitch,
49+
prismThemeDarkPath,
50+
prismThemeLightPath,
51+
prismThemePrefixPath
52+
)
4753
// 折叠代码
48-
loadExternalResource(prismjsAutoLoader, 'js').then((url) => {
54+
loadExternalResource(prismjsAutoLoader, 'js').then(url => {
4955
if (window?.Prism?.plugins?.autoloader) {
5056
window.Prism.plugins.autoloader.languages_path = prismjsPath
5157
}
@@ -62,7 +68,13 @@ const PrismMac = () => {
6268
/**
6369
* 加载Prism主题样式
6470
*/
65-
const loadPrismThemeCSS = (isDarkMode, prismThemeSwitch, prismThemeDarkPath, prismThemeLightPath, prismThemePrefixPath) => {
71+
const loadPrismThemeCSS = (
72+
isDarkMode,
73+
prismThemeSwitch,
74+
prismThemeDarkPath,
75+
prismThemeLightPath,
76+
prismThemePrefixPath
77+
) => {
6678
let PRISM_THEME
6779
let PRISM_PREVIOUS
6880
if (prismThemeSwitch) {
@@ -73,8 +85,14 @@ const loadPrismThemeCSS = (isDarkMode, prismThemeSwitch, prismThemeDarkPath, pri
7385
PRISM_THEME = prismThemeLightPath
7486
PRISM_PREVIOUS = prismThemeDarkPath
7587
}
76-
const previousTheme = document.querySelector(`link[href="${PRISM_PREVIOUS}"]`)
77-
if (previousTheme && previousTheme.parentNode && previousTheme.parentNode.contains(previousTheme)) {
88+
const previousTheme = document.querySelector(
89+
`link[href="${PRISM_PREVIOUS}"]`
90+
)
91+
if (
92+
previousTheme &&
93+
previousTheme.parentNode &&
94+
previousTheme.parentNode.contains(previousTheme)
95+
) {
7896
previousTheme.parentNode.removeChild(previousTheme)
7997
}
8098
loadExternalResource(PRISM_THEME, 'css')
@@ -103,14 +121,17 @@ const renderCollapseCode = (codeCollapse, codeCollapseExpandDefault) => {
103121
const collapseWrapper = document.createElement('div')
104122
collapseWrapper.className = 'collapse-wrapper w-full py-2'
105123
const panelWrapper = document.createElement('div')
106-
panelWrapper.className = 'border dark:border-gray-600 rounded-md hover:border-indigo-500 duration-200 transition-colors'
124+
panelWrapper.className =
125+
'border dark:border-gray-600 rounded-md hover:border-indigo-500 duration-200 transition-colors'
107126

108127
const header = document.createElement('div')
109-
header.className = 'flex justify-between items-center px-4 py-2 cursor-pointer select-none'
128+
header.className =
129+
'flex justify-between items-center px-4 py-2 cursor-pointer select-none'
110130
header.innerHTML = `<h3 class="text-lg font-medium">${language}</h3><svg class="transition-all duration-200 w-5 h-5 transform rotate-0" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M6.293 6.293a1 1 0 0 1 1.414 0L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-3 3a1 1 0 0 1-1.414 0l-3-3a1 1 0 0 1 0-1.414z" clip-rule="evenodd"/></svg>`
111131

112132
const panel = document.createElement('div')
113-
panel.className = 'invisible h-0 transition-transform duration-200 border-t border-gray-300'
133+
panel.className =
134+
'invisible h-0 transition-transform duration-200 border-t border-gray-300'
114135

115136
panelWrapper.appendChild(header)
116137
panelWrapper.appendChild(panel)
@@ -145,7 +166,7 @@ const renderMermaid = async(mermaidCDN) => {
145166
if (m.target.className === 'notion-code language-mermaid') {
146167
const chart = m.target.querySelector('code').textContent
147168
if (chart && !m.target.querySelector('.mermaid')) {
148-
const mermaidChart = document.createElement('div')
169+
const mermaidChart = document.createElement('pre')
149170
mermaidChart.className = 'mermaid'
150171
mermaidChart.innerHTML = chart
151172
m.target.appendChild(mermaidChart)
@@ -172,7 +193,10 @@ const renderMermaid = async(mermaidCDN) => {
172193
}
173194
})
174195
if (document.querySelector('#notion-article')) {
175-
observer.observe(document.querySelector('#notion-article'), { attributes: true, subtree: true })
196+
observer.observe(document.querySelector('#notion-article'), {
197+
attributes: true,
198+
subtree: true
199+
})
176200
}
177201
}
178202

@@ -234,7 +258,10 @@ const fixCodeLineStyle = () => {
234258
}
235259
}
236260
})
237-
observer.observe(document.querySelector('#notion-article'), { attributes: true, subtree: true })
261+
observer.observe(document.querySelector('#notion-article'), {
262+
attributes: true,
263+
subtree: true
264+
})
238265
setTimeout(() => {
239266
const preCodes = document.querySelectorAll('pre.notion-code')
240267
for (const preCode of preCodes) {

components/SEO.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ const getSEOMeta = (props, router, locale) => {
247247
}
248248
case '/404':
249249
return {
250-
title: `${siteInfo?.title} | 页面找不到啦`,
250+
title: `${siteInfo?.title} | ${locale.NAV.PAGE_NOT_FOUND}`,
251251
image: `${siteInfo?.pageCover}`
252252
}
253253
case '/tag':

conf/code.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = {
2828
// Mermaid 图表CDN
2929
MERMAID_CDN:
3030
process.env.NEXT_PUBLIC_MERMAID_CDN ||
31-
'https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.2.4/mermaid.min.js' // CDN
31+
'https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.4.0/mermaid.min.js' // CDN
3232

3333
// END********代码相关********
3434
}

lib/lang/en-US.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default {
1717
NAVIGATOR: 'NAV',
1818
ABOUT: 'About',
1919
MAIL: 'E-Mail',
20-
ARCHIVE: 'Archive'
20+
ARCHIVE: 'Archive',
21+
PAGE_NOT_FOUND: 'Page Not Found',
22+
PAGE_NOT_FOUND_REDIRECT: 'Page Not Found, Redirecting to Home Page...'
2123
},
2224
COMMON: {
2325
THEME: 'Theme',

lib/lang/zh-CN.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default {
1717
ABOUT: '关于',
1818
NAVIGATOR: '导航',
1919
MAIL: '邮箱',
20-
ARCHIVE: '归档'
20+
ARCHIVE: '归档',
21+
PAGE_NOT_FOUND: '页面找不到啦',
22+
PAGE_NOT_FOUND_REDIRECT: '页面无法加载,即将返回首页'
2123
},
2224
COMMON: {
2325
THEME: 'Theme',

styles/notion.css

+4
Original file line numberDiff line numberDiff line change
@@ -2027,6 +2027,10 @@ code.language-mermaid {
20272027
display: none;
20282028
}
20292029

2030+
.mermaid .invisible{
2031+
visibility: inherit;
2032+
}
2033+
20302034
.code-toolbar {
20312035
@apply w-full shadow-md pb-0;
20322036
}

themes/fukasawa/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const LayoutArchive = props => {
215215
*/
216216
const Layout404 = props => {
217217
const router = useRouter()
218+
const { locale } = useGlobal()
218219
useEffect(() => {
219220
// 延时3秒如果加载失败就返回首页
220221
setTimeout(() => {
@@ -232,7 +233,7 @@ const Layout404 = props => {
232233
<div className='dark:text-gray-200'>
233234
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
234235
<div className='inline-block text-left h-32 leading-10 items-center'>
235-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
236+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
236237
</div>
237238
</div>
238239
</div>

themes/game/index.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import NotionPage from '@/components/NotionPage'
66
import { PWA as initialPWA } from '@/components/PWA'
77
import ShareBar from '@/components/ShareBar'
88
import { siteConfig } from '@/lib/config'
9+
import { useGlobal } from '@/lib/global'
910
import { loadWowJS } from '@/lib/plugins/wow'
1011
import { deepClone, isBrowser, shuffleArray } from '@/lib/utils'
1112
import Link from 'next/link'
13+
import { useRouter } from 'next/router'
1214
import { createContext, useContext, useEffect, useRef, useState } from 'react'
1315
import Announcement from './components/Announcement'
1416
import { ArticleLock } from './components/ArticleLock'
@@ -30,7 +32,6 @@ import SideBarContent from './components/SideBarContent'
3032
import SideBarDrawer from './components/SideBarDrawer'
3133
import CONFIG from './config'
3234
import { Style } from './style'
33-
import { useRouter } from 'next/router'
3435

3536
// const AlgoliaSearchModal = dynamic(() => import('@/components/AlgoliaSearchModal'), { ssr: false })
3637

@@ -354,6 +355,7 @@ const LayoutSlug = props => {
354355
*/
355356
const Layout404 = props => {
356357
const router = useRouter()
358+
const { locale } = useGlobal()
357359
useEffect(() => {
358360
// 延时3秒如果加载失败就返回首页
359361
setTimeout(() => {
@@ -366,16 +368,21 @@ const Layout404 = props => {
366368
}, 3000)
367369
}, [])
368370

369-
return <>
370-
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
371-
<div className='dark:text-gray-200'>
372-
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
373-
<div className='inline-block text-left h-32 leading-10 items-center'>
374-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
375-
</div>
376-
</div>
371+
return (
372+
<>
373+
<div className='md:-mt-20 text-black w-full h-screen text-center justify-center content-center items-center flex flex-col'>
374+
<div className='dark:text-gray-200'>
375+
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'>
376+
<i className='mr-2 fas fa-spinner animate-spin' />
377+
404
378+
</h2>
379+
<div className='inline-block text-left h-32 leading-10 items-center'>
380+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
381+
</div>
377382
</div>
383+
</div>
378384
</>
385+
)
379386
}
380387

381388
/**

themes/gitbook/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ const LayoutArchive = props => {
438438
*/
439439
const Layout404 = props => {
440440
const router = useRouter()
441+
const { locale } = useGlobal()
441442
useEffect(() => {
442443
// 延时3秒如果加载失败就返回首页
443444
setTimeout(() => {
@@ -455,7 +456,7 @@ const Layout404 = props => {
455456
<div className='dark:text-gray-200'>
456457
<h2 className='inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top'><i className='mr-2 fas fa-spinner animate-spin' />404</h2>
457458
<div className='inline-block text-left h-32 leading-10 items-center'>
458-
<h2 className='m-0 p-0'>页面无法加载,即将返回首页</h2>
459+
<h2 className='m-0 p-0'>{locale.NAV.PAGE_NOT_FOUND_REDIRECT}</h2>
459460
</div>
460461
</div>
461462
</div>

0 commit comments

Comments
 (0)