mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
评论 插件相关
This commit is contained in:
@@ -6,56 +6,6 @@ import { useRouter } from 'next/router'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import Artalk from './Artalk'
|
||||
|
||||
const WalineComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/WalineComponent')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const CusdisComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/CusdisComponent')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const TwikooCompenent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Twikoo')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const GitalkComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Gitalk')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const UtterancesComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Utterances')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const GiscusComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Giscus')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const WebMentionComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/WebMention')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
|
||||
ssr: false
|
||||
})
|
||||
|
||||
/**
|
||||
* 评论组件
|
||||
* 只有当前组件在浏览器可见范围内才会加载内容
|
||||
@@ -114,10 +64,10 @@ const Comment = ({ frontMatter, className }) => {
|
||||
}
|
||||
|
||||
if (!frontMatter) {
|
||||
return <>Loading...</>
|
||||
return null
|
||||
}
|
||||
|
||||
if (isSearchEngineBot()) {
|
||||
if (isSearchEngineBot) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -204,4 +154,54 @@ const Comment = ({ frontMatter, className }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const WalineComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/WalineComponent')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const CusdisComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/CusdisComponent')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const TwikooCompenent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Twikoo')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const GitalkComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Gitalk')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const UtterancesComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Utterances')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const GiscusComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/Giscus')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
const WebMentionComponent = dynamic(
|
||||
() => {
|
||||
return import('@/components/WebMention')
|
||||
},
|
||||
{ ssr: false }
|
||||
)
|
||||
|
||||
const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
|
||||
ssr: false
|
||||
})
|
||||
|
||||
export default Comment
|
||||
|
||||
@@ -27,16 +27,9 @@ export const shuffleArray = array => {
|
||||
* google机器人
|
||||
* @returns
|
||||
*/
|
||||
export const isSearchEngineBot = () => {
|
||||
if (typeof navigator === 'undefined') {
|
||||
return false
|
||||
}
|
||||
// 获取用户代理字符串
|
||||
const userAgent = navigator.userAgent
|
||||
// 使用正则表达式检测是否包含搜索引擎爬虫关键字
|
||||
return /Googlebot|bingbot|Baidu/.test(userAgent)
|
||||
}
|
||||
|
||||
export const isSearchEngineBot =
|
||||
typeof navigator !== 'undefined' &&
|
||||
/Googlebot|bingbot|Baidu/.test(navigator.userAgent)
|
||||
/**
|
||||
* 组件持久化
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user