Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/ExternalPlugins.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { siteConfig } from '@/lib/config'
import { convertInnerUrl } from '@/lib/notion/convertInnerUrl'
import { convertInnerUrl } from '@/lib/db/notion/convertInnerUrl'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
Expand Down Expand Up @@ -182,7 +182,7 @@ const ExternalPlugin = props => {
// 执行注入脚本
// eslint-disable-next-line no-eval
if (GLOBAL_JS && GLOBAL_JS.trim() !== '') {
console.log('Inject JS:', GLOBAL_JS);
// console.log('Inject JS:', GLOBAL_JS);
}
eval(GLOBAL_JS)
})
Expand Down
2 changes: 1 addition & 1 deletion components/GlobalStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const GlobalStyle = () => {
const GLOBAL_CSS = siteConfig('GLOBAL_CSS')
// 如果这个字符串不为空,则打印显示
if (GLOBAL_CSS && GLOBAL_CSS.trim() !== '') {
console.log('Inject CSS:', GLOBAL_CSS);
// console.log('Inject CSS:', GLOBAL_CSS);
}
return (<style jsx global>{`
Expand Down
45 changes: 4 additions & 41 deletions components/NotionPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { siteConfig } from '@/lib/config'
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
import { compressImage, mapImgUrl } from '@/lib/db/notion/mapImage'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import mediumZoom from '@fisch0920/medium-zoom'
import 'katex/dist/katex.min.css'
Expand Down Expand Up @@ -116,15 +116,15 @@ const NotionPage = ({ post, className }) => {
return () => clearTimeout(timer)
}, [post])

const cleanBlockMap = cleanBlocksWithWarn(post.blockMap);

// const cleanBlockMap = cleanBlocksWithWarn(post?.blockMap);
// console.log('NotionPage render with post:', post);

return (
<div
id='notion-article'
className={`mx-auto overflow-hidden ${className || ''}`}>
<NotionRenderer
recordMap={cleanBlockMap}
recordMap={post?.blockMap}
mapPageUrl={mapPageUrl}
mapImageUrl={mapImgUrl}
components={{
Expand All @@ -143,43 +143,6 @@ const NotionPage = ({ post, className }) => {
)
}

function cleanBlocksWithWarn(blockMap) {
const cleanedBlocks = {};
const removedBlockIds = [];

for (const [id, block] of Object.entries(blockMap.block || {})) {
if (!block?.value?.id) {
removedBlockIds.push(id);
continue;
}

const newBlock = { ...block };

if (Array.isArray(newBlock.value.content)) {
// 递归清理 content 中无效的 blockId
newBlock.value.content = newBlock.value.content.filter((cid) => {
if (!blockMap.block[cid]?.value?.id) {
removedBlockIds.push(cid);
return false;
}
return true;
});
}

cleanedBlocks[id] = newBlock;
}

if (removedBlockIds.length) {
console.warn('Removed invalid blocks:', removedBlockIds);
}

return {
...blockMap,
block: cleanedBlocks,
};
}



/**
* 页面的数据库链接禁止跳转,只能查看
Expand Down
2 changes: 1 addition & 1 deletion components/PWA.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { compressImage } from '@/lib/notion/mapImage'
import { compressImage } from '@/lib/db/notion/mapImage'
import { isBrowser } from '../lib/utils'

/**
Expand Down
Loading
Loading