Merge pull request #1205 from tangly1024/fix/next-router

修复3.16.0编译打包问题
This commit is contained in:
tangly1024
2023-06-27 14:01:05 +08:00
committed by GitHub
4 changed files with 12 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ assignees: tangly1024
- 操作系统: [例如. iOS, Android, macOS, windows]
- 浏览器 [例如. chrome, safari, firefox]
- NotionNext版本 [e.g. 3.13.6]
- 主题 [例如. hexo]
**补充说明**
与问题相关的其它说明

View File

@@ -77,7 +77,7 @@ const NotionPage = ({ post, className }) => {
Tweet
}} />
<PrismMac />
<PrismMac/>
</div>
}

View File

@@ -1,4 +1,6 @@
import React, { useEffect } from 'react'
'use client'
import { useEffect } from 'react'
import Prism from 'prismjs'
// 所有语言的prismjs 使用autoloader引入
// import 'prismjs/plugins/autoloader/prism-autoloader'
@@ -12,7 +14,7 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
// mermaid图
import BLOG from '@/blog.config'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import { useRouter } from 'next/router'
import { useRouter } from 'next/navigation'
/**
* @author https://github.com/txs/
@@ -27,7 +29,6 @@ const PrismMac = () => {
}
loadExternalResource(BLOG.PRISM_THEME_PATH, 'css')
loadExternalResource(BLOG.PRISM_JS_AUTO_LOADER, 'js').then((url) => {
// console.log('渲染公式图表')
if (window?.Prism?.plugins?.autoloader) {
window.Prism.plugins.autoloader.languages_path = BLOG.PRISM_JS_PATH
}
@@ -63,10 +64,11 @@ const renderMermaid = async() => {
}
}
if (needLoad) {
const url = await loadExternalResource(BLOG.MERMAID_CDN, 'js')
const mermaid = window.mermaid
console.log('mermaid加载成功', url, mermaid)
mermaid.contentLoaded()
loadExternalResource(BLOG.MERMAID_CDN, 'js').then(url => {
// console.log('mermaid加载成功', url, mermaid)
const mermaid = window.mermaid
mermaid.contentLoaded()
})
}
}
}

View File

@@ -45,7 +45,7 @@ export async function getGlobalNotionData({
* @returns
*/
function getLatestPosts({ allPages, from, latestPostCount }) {
const allPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published')
const allPosts = allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
const latestPosts = Object.create(allPosts).sort((a, b) => {
const dateA = new Date(a?.lastEditedTime || a?.createdTime || a?.date?.start_date)