mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
Merge pull request #3099 from qixing-jk/feat-spoiler-text-plugin
Feat spoiler text plugin 支持spoiler text
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
|
||||
import { isBrowser } from '@/lib/utils'
|
||||
import { isBrowser, loadExternalResource } from '@/lib/utils'
|
||||
import mediumZoom from '@fisch0920/medium-zoom'
|
||||
import 'katex/dist/katex.min.css'
|
||||
import dynamic from 'next/dynamic'
|
||||
@@ -17,6 +17,7 @@ const NotionPage = ({ post, className }) => {
|
||||
// 是否关闭数据库和画册的点击跳转
|
||||
const POST_DISABLE_GALLERY_CLICK = siteConfig('POST_DISABLE_GALLERY_CLICK')
|
||||
const POST_DISABLE_DATABASE_CLICK = siteConfig('POST_DISABLE_DATABASE_CLICK')
|
||||
const SPOILER_TEXT_TAG = siteConfig('SPOILER_TEXT_TAG')
|
||||
|
||||
const zoom =
|
||||
isBrowser &&
|
||||
@@ -84,6 +85,21 @@ const NotionPage = ({ post, className }) => {
|
||||
}
|
||||
}, [post])
|
||||
|
||||
useEffect(() => {
|
||||
// Spoiler文本功能
|
||||
if (SPOILER_TEXT_TAG) {
|
||||
import('lodash/escapeRegExp').then(escapeRegExp => {
|
||||
Promise.all([
|
||||
loadExternalResource('/js/spoilerText.js', 'js'),
|
||||
loadExternalResource('/css/spoiler-text.css', 'css')
|
||||
]).then(() => {
|
||||
window.textToSpoiler &&
|
||||
window.textToSpoiler(escapeRegExp.default(SPOILER_TEXT_TAG))
|
||||
})
|
||||
})
|
||||
}
|
||||
}, [post])
|
||||
|
||||
return (
|
||||
<div
|
||||
id='notion-article'
|
||||
|
||||
Reference in New Issue
Block a user