Skip to content

Commit

Permalink
Merge pull request #1791 from tangly1024/feat/TianliGPT
Browse files Browse the repository at this point in the history
TianliGPT
  • Loading branch information
tangly1024 authored Jan 21, 2024
2 parents 05ea1dc + e7453b0 commit 5d2a32b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
5 changes: 5 additions & 0 deletions blog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ const BLOG = {
STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关

// ********挂件组件相关********
// AI 文章摘要生成 @see https://docs_s.tianli0.top/
TianliGPT_CSS: process.env.NEXT_PUBLIC_TIANLI_GPT_CSS || 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.15.2/tianli_gpt.css',
TianliGPT_JS: process.env.NEXT_PUBLIC_TIANLI_GPT_JS || 'https://cdn1.tianli0.top/gh/zhheo/Post-Abstract-AI@0.15.2/tianli_gpt.js',
TianliGPT_KEY: process.env.NEXT_PUBLIC_TIANLI_GPT_KEY || '',

// Chatbase 是否显示chatbase机器人 https://www.chatbase.co/
CHATBASE_ID: process.env.NEXT_PUBLIC_CHATBASE_ID || null,
// WebwhizAI 机器人 @see /~https://github.com/webwhiz-ai/webwhiz
Expand Down
4 changes: 1 addition & 3 deletions components/Artalk.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { siteConfig } from '@/lib/config'
import { loadExternalResource } from '@/lib/utils'
// import { loadExternalResource } from '@/lib/utils'
import { useEffect } from 'react'

/**
* Giscus评论 @see https://giscus.app/zh-CN
* Contribute by @txs /~https://github.com/txs/NotionNext/commit/1bf7179d0af21fb433e4c7773504f244998678cb
* Artalk 自托管评论系统 @see https://artalk.js.org/
* @returns {JSX.Element}
* @constructor
*/
Expand Down
3 changes: 3 additions & 0 deletions components/ExternalPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { siteConfig } from '@/lib/config'
import dynamic from 'next/dynamic'
import LA51 from './LA51'
import WebWhiz from './Webwhiz'
import TianLiGPT from './TianliGPT'

const TwikooCommentCounter = dynamic(() => import('@/components/TwikooCommentCounter'), { ssr: false })
const DebugPanel = dynamic(() => import('@/components/DebugPanel'), { ssr: false })
Expand Down Expand Up @@ -71,6 +72,7 @@ const ExternalPlugin = (props) => {
const ANALYTICS_51LA_ID = siteConfig('ANALYTICS_51LA_ID')
const ANALYTICS_51LA_CK = siteConfig('ANALYTICS_51LA_CK')
const DIFY_CHATBOT_ENABLED = siteConfig('DIFY_CHATBOT_ENABLED')
const TIANLI_KEY = siteConfig('TianliGPT_KEY')

if (DISABLE_PLUGIN) {
return null
Expand Down Expand Up @@ -98,6 +100,7 @@ const ExternalPlugin = (props) => {
{!CAN_COPY && <DisableCopy />}
{WEB_WHIZ_ENABLED && <WebWhiz />}
{AD_WWADS_BLOCK_DETECT && <AdBlockDetect />}
{TIANLI_KEY && <TianLiGPT/>}
<VConsole />
<LoadingProgress />
<AosAnimation />
Expand Down
41 changes: 41 additions & 0 deletions components/TianliGPT.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable no-unused-vars */
/* eslint-disable camelcase */
import { siteConfig } from '@/lib/config'
import { loadExternalResource } from '@/lib/utils'
import { useEffect } from 'react'
/**
* TianliGpt AI文章摘要生成工具 @see https://docs_s.tianli0.top/
* @returns {JSX.Element}
* @constructor
*/

const TianLiGPT = () => {
const tianliKey = siteConfig('TianliGPT_KEY')
const tianliCss = siteConfig('TianliGPT_CSS')
const tianliJs = siteConfig('TianliGPT_JS')

useEffect(() => {
initArtalk()
}, [])

if (!tianliKey) {
return null
}

const initArtalk = async () => {
console.log('loading tianliGPT', tianliKey, tianliCss, tianliJs)

if (!tianliKey) {
return
}
await loadExternalResource(tianliCss, 'css')

window.tianliGPT_postSelector = '#notion-article';
window.tianliGPT_key = 'f50e6b018a094fbb0d7c';

await loadExternalResource(tianliJs, 'js')
}
return <></>
}

export default TianLiGPT

0 comments on commit 5d2a32b

Please sign in to comment.