mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-06 23:16:52 +00:00
画册视图允许关闭跳转
This commit is contained in:
@@ -126,6 +126,8 @@ const BLOG = {
|
|||||||
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
|
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
|
||||||
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制
|
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制
|
||||||
|
|
||||||
|
POST_DISABLE_GALLERY_CLICK: process.env.NEXT_PUBLIC_POST_SORT_BY || false, // 画册视图禁止点击,方便在友链页面的画册插入链接
|
||||||
|
|
||||||
// 鼠标点击烟花特效
|
// 鼠标点击烟花特效
|
||||||
FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关
|
FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关
|
||||||
// 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩
|
// 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { NotionRenderer } from 'react-notion-x'
|
import { NotionRenderer } from 'react-notion-x'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
// import mediumZoom from '@fisch0920/medium-zoom'
|
import mediumZoom from '@fisch0920/medium-zoom'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect, useRef } from 'react'
|
||||||
// import { Code } from 'react-notion-x/build/third-party/code'
|
// import { Code } from 'react-notion-x/build/third-party/code'
|
||||||
import TweetEmbed from 'react-tweet-embed'
|
import TweetEmbed from 'react-tweet-embed'
|
||||||
|
|
||||||
import 'katex/dist/katex.min.css'
|
import 'katex/dist/katex.min.css'
|
||||||
import { mapImgUrl } from '@/lib/notion/mapImage'
|
import { mapImgUrl } from '@/lib/notion/mapImage'
|
||||||
|
import BLOG from '@/blog.config'
|
||||||
|
import { isBrowser } from '@/lib/utils'
|
||||||
|
|
||||||
const Code = dynamic(() =>
|
const Code = dynamic(() =>
|
||||||
import('react-notion-x/build/third-party/code').then(async (m) => {
|
import('react-notion-x/build/third-party/code').then(async (m) => {
|
||||||
@@ -21,6 +23,7 @@ const Equation = dynamic(() =>
|
|||||||
return m.Equation
|
return m.Equation
|
||||||
}), { ssr: false }
|
}), { ssr: false }
|
||||||
)
|
)
|
||||||
|
|
||||||
const Pdf = dynamic(
|
const Pdf = dynamic(
|
||||||
() => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf),
|
() => import('react-notion-x/build/third-party/pdf').then((m) => m.Pdf),
|
||||||
{
|
{
|
||||||
@@ -51,6 +54,34 @@ const NotionPage = ({ post, className }) => {
|
|||||||
autoScrollToTarget()
|
autoScrollToTarget()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const zoom = typeof window !== 'undefined' && mediumZoom({
|
||||||
|
container: '.notion-viewport',
|
||||||
|
background: 'rgba(0, 0, 0, 0.2)',
|
||||||
|
margin: getMediumZoomMargin()
|
||||||
|
})
|
||||||
|
const zoomRef = useRef(zoom ? zoom.clone() : null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 将相册gallery下的图片加入放大功能
|
||||||
|
if (JSON.parse(BLOG.POST_DISABLE_GALLERY_CLICK)) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (isBrowser()) {
|
||||||
|
const imgList = document?.querySelectorAll('.notion-collection-card-cover img')
|
||||||
|
if (imgList && zoomRef.current) {
|
||||||
|
for (let i = 0; i < imgList.length; i++) {
|
||||||
|
(zoomRef.current).attach(imgList[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const cards = document.getElementsByClassName('notion-collection-card')
|
||||||
|
for (const e of cards) {
|
||||||
|
e.removeAttribute('href')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 800)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!post || !post.blockMap) {
|
if (!post || !post.blockMap) {
|
||||||
return <>{post?.summary || ''}</>
|
return <>{post?.summary || ''}</>
|
||||||
}
|
}
|
||||||
@@ -100,4 +131,25 @@ const mapPageUrl = id => {
|
|||||||
return '/' + id.replace(/-/g, '')
|
return '/' + id.replace(/-/g, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缩放
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function getMediumZoomMargin() {
|
||||||
|
const width = window.innerWidth
|
||||||
|
|
||||||
|
if (width < 500) {
|
||||||
|
return 8
|
||||||
|
} else if (width < 800) {
|
||||||
|
return 20
|
||||||
|
} else if (width < 1280) {
|
||||||
|
return 30
|
||||||
|
} else if (width < 1600) {
|
||||||
|
return 40
|
||||||
|
} else if (width < 1920) {
|
||||||
|
return 48
|
||||||
|
} else {
|
||||||
|
return 72
|
||||||
|
}
|
||||||
|
}
|
||||||
export default NotionPage
|
export default NotionPage
|
||||||
|
|||||||
Reference in New Issue
Block a user