Merge pull request #3099 from qixing-jk/feat-spoiler-text-plugin

Feat spoiler text plugin 支持spoiler text
This commit is contained in:
tangly1024
2025-01-01 15:38:58 +08:00
committed by GitHub
4 changed files with 126 additions and 1 deletions

View File

@@ -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'