diff --git a/components/Gitalk.js b/components/Gitalk.js
index 23bda017..b60d0cd0 100644
--- a/components/Gitalk.js
+++ b/components/Gitalk.js
@@ -21,6 +21,11 @@ const Gitalk = ({ frontMatter }) => {
await loadExternalResource(gitalkCSSCDN, 'css')
await loadExternalResource(gitalkJSCDN, 'js')
const Gitalk = window.Gitalk
+ if (!Gitalk) {
+ // 可以加入延时重试
+ console.warn('Gitalk 初始化失败')
+ return
+ }
const gitalk = new Gitalk({
clientID: clientId,
clientSecret: clientSecret,
diff --git a/components/GlobalHead.js b/components/GlobalHead.js
index 92465d4a..4723c218 100644
--- a/components/GlobalHead.js
+++ b/components/GlobalHead.js
@@ -85,7 +85,6 @@ const GlobalHead = (props) => {
* @param {*} router
*/
const getSEOMeta = (props, router, global) => {
- console.log(props, router)
const { locale } = global
const { post, tag, category, page } = props
const keyword = router?.query?.s
diff --git a/components/NotionPage.js b/components/NotionPage.js
index 58153fbd..b3be2174 100644
--- a/components/NotionPage.js
+++ b/components/NotionPage.js
@@ -7,13 +7,6 @@ import { isBrowser } from '@/lib/utils'
import { siteConfig } from '@/lib/config'
import { NotionRenderer } from 'react-notion-x'
-// Notion渲染
-// const NotionRenderer = dynamic(() => import('react-notion-x').then(async (m) => {
-// return m.NotionRenderer
-// }), {
-// ssr: false
-// })
-
const Code = dynamic(() =>
import('react-notion-x/build/third-party/code').then(async (m) => {
return m.Code
diff --git a/lib/utils.js b/lib/utils.js
index a892c275..d632e1c3 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -34,7 +34,7 @@ export const memorize = (Component) => {
// 转换外链
export function sliceUrlFromHttp(str) {
// 检查字符串是否包含http
- if (str.includes('http')) {
+ if (str.includes('http:') || str.includes('https:')) {
// 如果包含,找到http的位置
const index = str.indexOf('http');
// 返回http之后的部分
@@ -48,7 +48,7 @@ export function sliceUrlFromHttp(str) {
// 检查是否外链
export function checkContainHttp(str) {
// 检查字符串是否包含http
- if (str.includes('http')) {
+ if (str.includes('http:') || str.includes('https:')) {
// 如果包含,找到http的位置
return str.indexOf('http') > -1
} else {
diff --git a/pages/[prefix]/[slug]/[...suffix].js b/pages/[prefix]/[slug]/[...suffix].js
index 67f099d7..f33fe20f 100644
--- a/pages/[prefix]/[slug]/[...suffix].js
+++ b/pages/[prefix]/[slug]/[...suffix].js
@@ -5,6 +5,7 @@ import { idToUuid } from 'notion-utils'
import { getNotion } from '@/lib/notion/getNotion'
import Slug, { getRecommendPost } from '..'
import { uploadDataToAlgolia } from '@/lib/algolia'
+import { checkContainHttp } from '@/lib/utils'
/**
* 根据notion的slug访问页面
@@ -30,8 +31,10 @@ export async function getStaticPaths() {
const from = 'slug-paths'
const { allPages } = await getGlobalData({ from })
+
return {
- paths: allPages?.filter(row => hasMultipleSlashes(row.slug) && row.type.indexOf('Menu') < 0).map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1], suffix: row.slug.split('/').slice(1) } })),
+ paths: allPages?.filter(row => hasMultipleSlashes(row.slug) && row.type.indexOf('Menu') < 0 && !checkContainHttp(row.slug))
+ .map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1], suffix: row.slug.split('/').slice(1) } })),
fallback: true
}
}
diff --git a/pages/[prefix]/[slug]/index.js b/pages/[prefix]/[slug]/index.js
index 4571b791..0c8fbffb 100644
--- a/pages/[prefix]/[slug]/index.js
+++ b/pages/[prefix]/[slug]/index.js
@@ -5,6 +5,7 @@ import { idToUuid } from 'notion-utils'
import { getNotion } from '@/lib/notion/getNotion'
import Slug, { getRecommendPost } from '..'
import { uploadDataToAlgolia } from '@/lib/algolia'
+import { checkContainHttp } from '@/lib/utils'
/**
* 根据notion的slug访问页面
@@ -26,8 +27,10 @@ export async function getStaticPaths() {
const from = 'slug-paths'
const { allPages } = await getGlobalData({ from })
+ const paths = allPages?.filter(row => row.slug.indexOf('/') > 0 && !checkContainHttp(row.slug) && row.type.indexOf('Menu') < 0)
+ .map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1] } }))
return {
- paths: allPages?.filter(row => row.slug.indexOf('/') > 0 && row.type.indexOf('Menu') < 0).map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1] } })),
+ paths: paths,
fallback: true
}
}
diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js
index 036f585b..f9827f9b 100644
--- a/pages/[prefix]/index.js
+++ b/pages/[prefix]/index.js
@@ -8,7 +8,7 @@ import { getNotion } from '@/lib/notion/getNotion'
import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents'
import { getLayoutByTheme } from '@/themes/theme'
import md5 from 'js-md5'
-import { isBrowser } from '@/lib/utils'
+import { checkContainHttp, isBrowser } from '@/lib/utils'
import { uploadDataToAlgolia } from '@/lib/algolia'
import { siteConfig } from '@/lib/config'
@@ -82,8 +82,10 @@ export async function getStaticPaths() {
const from = 'slug-paths'
const { allPages } = await getGlobalData({ from })
+ const paths = allPages?.filter(row => row.slug.indexOf('/') > 0 && !checkContainHttp(row.slug) && row.type.indexOf('Menu') < 0)
+ .map(row => ({ params: { prefix: row.slug } }))
return {
- paths: allPages?.filter(row => row.slug.indexOf('/') < 0 && row.type.indexOf('Menu') < 0).map(row => ({ params: { prefix: row.slug } })),
+ paths: paths,
fallback: true
}
}
diff --git a/pages/_app.js b/pages/_app.js
index 6bf73a76..9b6a74bc 100644
--- a/pages/_app.js
+++ b/pages/_app.js
@@ -17,16 +17,21 @@ import useAdjustStyle from '@/hooks/useAdjustStyle'
// 各种扩展插件 这个要阻塞引入
import ExternalPlugins from '@/components/ExternalPlugins'
-import { THEME } from '@/blog.config'
import GlobalHead from '@/components/GlobalHead'
+import BLOG from '@/blog.config'
+/**
+ * App挂载DOM 入口文件
+ * @param {*} param0
+ * @returns
+ */
const MyApp = ({ Component, pageProps }) => {
// 一些可能出现 bug 的样式,可以统一放入该钩子进行调整
useAdjustStyle();
const route = useRouter()
const queryParam = useMemo(() => {
- return getQueryParam(route.asPath, 'theme') || THEME
+ return getQueryParam(route.asPath, 'theme') || pageProps?.NOTION_CONFIG?.THEME || BLOG.THEME
}, [route])
// 整体布局
diff --git a/themes/heo/index.js b/themes/heo/index.js
index 5e7aa3ab..54d328ed 100644
--- a/themes/heo/index.js
+++ b/themes/heo/index.js
@@ -65,13 +65,10 @@ const LayoutBase = props => {
{/* 通知横幅 */}
{router.route === '/'
? <>
-