diff --git a/components/NotByAI.js b/components/NotByAI.js new file mode 100644 index 00000000..b8c99e0a --- /dev/null +++ b/components/NotByAI.js @@ -0,0 +1,66 @@ +import { useGlobal } from '@/lib/global' + +const LANGS = { + 'en-US': 'en', + 'zh-CN': 'zh', + 'zh-HK': 'zh-HK', + 'zh-TW': 'zh-TW', + 'fr-FR': 'fr', + 'tr-TR': 'tr', + 'ja-JP': 'ja' +} + +/** + * 获取当前not-by-ai文件路径 + * 如果匹配到完整的“国家-地区”语言,则显示国家的语言 + * @returns string + */ +export function generateNotByAiPath(langString) { + const supportedLocales = Object.keys(LANGS) + let userLocale + + // 将语言字符串拆分为语言和地区代码,例如将 "zh-CN" 拆分为 "zh" 和 "CN" + const [language, region] = langString?.split(/[-_]/) + + // 优先匹配语言和地区都匹配的情况 + const specificLocale = `${language}-${region}` + if (supportedLocales.includes(specificLocale)) { + userLocale = LANGS[specificLocale] + } + + // 然后尝试匹配只有语言匹配的情况 + if (!userLocale) { + const languageOnlyLocales = supportedLocales.filter(locale => + locale.startsWith(language) + ) + if (languageOnlyLocales.length > 0) { + userLocale = LANGS[languageOnlyLocales[0]] + } + } + + // 如果还没匹配到,则返回最接近的 + if (!userLocale) { + const fallbackLocale = supportedLocales.find(locale => + locale.startsWith('en') + ) + userLocale = LANGS[fallbackLocale] + } + + return userLocale ?? 'zh' +} + +/** + * 版权声明 + * @returns + */ +export default function NotByAI() { + const { lang, isDarkMode } = useGlobal() + + return ( + not-by-ai + ) +} diff --git a/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..a9fcb382 --- /dev/null +++ b/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..49cac441 --- /dev/null +++ b/public/svg/not-by-ai/en/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..031a9abe --- /dev/null +++ b/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..41dcd8b5 --- /dev/null +++ b/public/svg/not-by-ai/fr/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..0ba40b75 --- /dev/null +++ b/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..53775d31 --- /dev/null +++ b/public/svg/not-by-ai/ja/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..a8fdbafe --- /dev/null +++ b/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..4e79df1e --- /dev/null +++ b/public/svg/not-by-ai/tr/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..18c32c01 --- /dev/null +++ b/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..872377df --- /dev/null +++ b/public/svg/not-by-ai/zh-HK/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..18c32c01 --- /dev/null +++ b/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..872377df --- /dev/null +++ b/public/svg/not-by-ai/zh-TW/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-black.svg b/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-black.svg new file mode 100644 index 00000000..637cc2a8 --- /dev/null +++ b/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-black.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-white.svg b/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-white.svg new file mode 100644 index 00000000..a0590bc8 --- /dev/null +++ b/public/svg/not-by-ai/zh/Written-By-Human-Not-By-AI-Badge-white.svg @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/commerce/components/ArticleCopyright.js b/themes/commerce/components/ArticleCopyright.js index 67c65bab..b418a655 100644 --- a/themes/commerce/components/ArticleCopyright.js +++ b/themes/commerce/components/ArticleCopyright.js @@ -4,8 +4,9 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import CONFIG from '../config' import { siteConfig } from '@/lib/config' +import NotByAI from '@/components/NotByAI' -export default function ArticleCopyright () { +export default function ArticleCopyright() { const router = useRouter() const [path, setPath] = useState(siteConfig('LINK') + router.asPath) useEffect(() => { @@ -14,22 +15,24 @@ export default function ArticleCopyright () { const { locale } = useGlobal() - if (!CONFIG.ARTICLE_COPYRIGHT) { + if (!siteConfig('COMMERCE_ARTICLE_COPYRIGHT', null, CONFIG)) { return <> } return ( -
-
) diff --git a/themes/heo/config.js b/themes/heo/config.js index 4a037982..b093f61f 100644 --- a/themes/heo/config.js +++ b/themes/heo/config.js @@ -146,6 +146,7 @@ const CONFIG = { HEO_ARTICLE_ADJACENT: true, // 显示上一篇下一篇文章推荐 HEO_ARTICLE_COPYRIGHT: true, // 显示文章版权声明 + HEO_ARTICLE_NOT_BY_AI: false, // 显示非AI写作 HEO_ARTICLE_RECOMMEND: true, // 文章关联推荐 HEO_WIDGET_LATEST_POSTS: true, // 显示最新文章卡 diff --git a/themes/hexo/components/ArticleCopyright.js b/themes/hexo/components/ArticleCopyright.js index af3808a2..a7be768d 100644 --- a/themes/hexo/components/ArticleCopyright.js +++ b/themes/hexo/components/ArticleCopyright.js @@ -4,8 +4,9 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import CONFIG from '../config' import { siteConfig } from '@/lib/config' +import NotByAI from '@/components/NotByAI' -export default function ArticleCopyright () { +export default function ArticleCopyright() { const router = useRouter() const [path, setPath] = useState(siteConfig('LINK') + router.asPath) useEffect(() => { @@ -19,17 +20,19 @@ export default function ArticleCopyright () { } return ( -
-