From add19cc4add82450a22f2332dda1440fb8bd014d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 12 Dec 2022 12:52:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Medium=E4=B8=BB=E9=A2=98=E5=A4=9C=E9=97=B4?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E9=85=8D=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/medium/LayoutBase.js | 2 +- themes/medium/components/ArticleAround.js | 4 ++-- themes/medium/components/ArticleDetail.js | 3 ++- themes/medium/components/BlogPostCard.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/themes/medium/LayoutBase.js b/themes/medium/LayoutBase.js index 29ea9e32..427b3676 100644 --- a/themes/medium/LayoutBase.js +++ b/themes/medium/LayoutBase.js @@ -24,7 +24,7 @@ const LayoutBase = props => { const router = useRouter() return ( -
+
{/* 桌面端左侧菜单 */} diff --git a/themes/medium/components/ArticleAround.js b/themes/medium/components/ArticleAround.js index 0c4363cc..cdedb1b9 100644 --- a/themes/medium/components/ArticleAround.js +++ b/themes/medium/components/ArticleAround.js @@ -9,14 +9,14 @@ export default function ArticleAround ({ prev, next }) { if (!prev || !next) { return <> } - return
+ return
{prev.title} - {next.title} + {next.title} diff --git a/themes/medium/components/ArticleDetail.js b/themes/medium/components/ArticleDetail.js index ea129207..1fffc2a0 100644 --- a/themes/medium/components/ArticleDetail.js +++ b/themes/medium/components/ArticleDetail.js @@ -21,7 +21,7 @@ export const ArticleDetail = props => { return
{/* title */} -

{post?.title}

+

{post?.title}

{/* meta */}
@@ -61,6 +61,7 @@ export const ArticleDetail = props => { data-ad-slot="3806269138" />
+
{CONFIG_MEDIUM.POST_DETAIL_CATEGORY && post.category && } diff --git a/themes/medium/components/BlogPostCard.js b/themes/medium/components/BlogPostCard.js index 7cbadf83..179ecdcd 100644 --- a/themes/medium/components/BlogPostCard.js +++ b/themes/medium/components/BlogPostCard.js @@ -19,7 +19,7 @@ const BlogPostCard = ({ post, showSummary }) => { {post.title} From c44e1d4c71176ac7a5d4c22cc969d216c07b5394 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 20 Dec 2022 20:57:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?twikoo=20=E8=AF=84=E8=AE=BA=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 16 ++++++++++++---- components/Comment.js | 11 +++++++++++ components/Twikoo.js | 27 +++++++++++++++++++++++++++ package.json | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 components/Twikoo.js diff --git a/blog.config.js b/blog.config.js index 4baa8fe3..9d5becac 100644 --- a/blog.config.js +++ b/blog.config.js @@ -66,7 +66,13 @@ const BLOG = { WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题 - // 评论互动 可同时开启多个支持 GISCUS CUSDIS UTTERRANCES GITALK + // ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK + + // twikoo + COMMENT_TWIKOO_ENV_ID: process.env.NEXT_PUBLIC_COMMENT_ENV_ID || '', // TWIKOO地址 腾讯云环境填 envId;Vercel 环境域名地址(https://xxx.vercel.app) + + // utterance + COMMENT_UTTERRANCES_REPO: process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext'; 更多文档参考 https://utteranc.es/ // giscus @see https://giscus.app/ COMMENT_GISCUS_REPO: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO || '', // 你的Github仓库名 e.g 'tangly1024/NotionNext' @@ -84,8 +90,6 @@ const BLOG = { COMMENT_CUSDIS_HOST: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_HOST || 'https://cusdis.com', // data-host, change this if you're using self-hosted version COMMENT_CUSDIS_SCRIPT_SRC: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC || 'https://cusdis.com/js/cusdis.es.js', // change this if you're using self-hosted version - COMMENT_UTTERRANCES_REPO: process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext'; 更多文档参考 https://utteranc.es/ - // gitalk评论插件 更多参考 https://gitalk.github.io/ COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名,例如 'NotionNext' COMMENT_GITALK_OWNER: process.env.NEXT_PUBLIC_COMMENT_GITALK_OWNER || '', // 你的用户名 e.g tangly1024 @@ -106,7 +110,9 @@ const BLOG = { COMMENT_WALINE_SERVER_URL: process.env.NEXT_PUBLIC_WALINE_SERVER_URL || '', // 请配置完整的Waline评论地址 例如 hhttps://preview-waline.tangly1024.com @see https://waline.js.org/guide/get-started.html COMMENT_WALINE_RECENT: process.env.NEXT_PUBLIC_WALINE_RECENT || false, // 最新评论 - // 站点统计 + // <---- 评论插件 + + // ----> 站点统计 ANALYTICS_BUSUANZI_ENABLE: true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ ANALYTICS_BAIDU_ID: process.env.NEXT_PUBLIC_ANALYTICS_BAIDU_ID || '', // e.g 只需要填写百度统计的id,[baidu_id] -> https://hm.baidu.com/hm.js?[baidu_id] ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id] @@ -118,6 +124,8 @@ const BLOG = { SEO_GOOGLE_SITE_VERIFICATION: process.env.NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code + // <---- 站点统计 + // 谷歌广告 ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx diff --git a/components/Comment.js b/components/Comment.js index c1ae3d2b..613fad88 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -19,6 +19,13 @@ const CusdisComponent = dynamic( { ssr: false } ) +const TwikooCompenent = dynamic( + () => { + return import('@/components/Twikoo') + }, + { ssr: false } +) + const GitalkComponent = dynamic( () => { return import('@/components/Gitalk') @@ -66,6 +73,10 @@ const Comment = ({ frontMatter }) => {
+ { BLOG.COMMENT_TWIKOO_ENV_ID && (
+ +
)} + { BLOG.COMMENT_WALINE_SERVER_URL && (
) } diff --git a/components/Twikoo.js b/components/Twikoo.js new file mode 100644 index 00000000..bc6baa06 --- /dev/null +++ b/components/Twikoo.js @@ -0,0 +1,27 @@ +import BLOG from '@/blog.config' +import React from 'react' +import twikoo from 'twikoo' + +/** + * Giscus评论 @see https://giscus.app/zh-CN + * Contribute by @txs https://github.com/txs/NotionNext/commit/1bf7179d0af21fb433e4c7773504f244998678cb + * @returns {JSX.Element} + * @constructor + */ + +const Twikoo = ({ isDarkMode }) => { + React.useEffect(() => { + twikoo({ + envId: BLOG.COMMENT_TWIKOO_ENV_ID, // 腾讯云环境填 envId;Vercel 环境填地址(https://xxx.vercel.app) + el: '#twikoo', // 容器元素 + lang: BLOG.LANG // 用于手动设定评论区语言,支持的语言列表 https://github.com/imaegoo/twikoo/blob/main/src/client/utils/i18n/index.js + // region: 'ap-guangzhou', // 环境地域,默认为 ap-shanghai,腾讯云环境填 ap-shanghai 或 ap-guangzhou;Vercel 环境不填 + // path: location.pathname, // 用于区分不同文章的自定义 js 路径,如果您的文章路径不是 location.pathname,需传此参数 + }) + }) + return ( +
+ ) +} + +export default Twikoo diff --git a/package.json b/package.json index c1a01253..949612e1 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "react-notion-x": "6.15.6", "react-share": "^4.4.0", "smoothscroll-polyfill": "^0.4.4", + "twikoo": "^1.6.8", "typed.js": "^2.0.12", "use-ackee": "^3.0.0", "valine": "^1.4.18"