From 3f2de9e3d4703122ed0e3e03f36759adb5f25df9 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 17 Jan 2022 21:53:52 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 175 +++++++++++------- components/Ackee.js | 15 +- components/Comment.js | 41 ++-- components/CommonHead.js | 22 +-- components/CommonScript.js | 37 ++-- components/Cusdis.js | 9 +- .../NEXT/components => components}/Tabs.js | 0 components/Utterances.js | 8 +- lib/cjk.js | 2 +- lib/gtag.js | 3 +- lib/notion/getAllPosts.js | 2 +- lib/notion/getNotionData.js | 4 +- lib/notion/getPostBlocks.js | 4 +- lib/rss.js | 30 +-- next-sitemap.config.js | 2 +- pages/_app.js | 13 +- pages/_document.js | 5 +- pages/feed.js | 9 +- pages/index.js | 12 +- pages/page/[page].js | 12 +- tailwind.config.js | 6 +- themes/Fukasawa/LayoutArchive.js | 4 +- themes/Fukasawa/LayoutCategoryIndex.js | 4 +- themes/Fukasawa/LayoutSlug.js | 2 +- themes/Fukasawa/LayoutTagIndex.js | 4 +- themes/Fukasawa/components/AsideLeft.js | 2 +- themes/Fukasawa/components/BlogCard.js | 4 +- themes/Fukasawa/components/BlogListPage.js | 2 +- themes/Fukasawa/components/BlogPostArchive.js | 4 +- themes/Fukasawa/components/Logo.js | 2 +- .../Fukasawa/components/PaginationSimple.js | 2 +- themes/Fukasawa/components/SiteInfo.js | 6 +- themes/NEXT/Layout404.js | 2 +- themes/NEXT/LayoutArchive.js | 4 +- themes/NEXT/LayoutCategory.js | 4 +- themes/NEXT/LayoutCategoryIndex.js | 4 +- themes/NEXT/LayoutSearch.js | 4 +- themes/NEXT/LayoutSlug.js | 2 +- themes/NEXT/LayoutTag.js | 4 +- themes/NEXT/LayoutTagIndex.js | 4 +- themes/NEXT/components/ArticleDetail.js | 4 +- themes/NEXT/components/BlogPostArchive.js | 4 +- themes/NEXT/components/BlogPostCard.js | 6 +- themes/NEXT/components/BlogPostListPage.js | 2 +- themes/NEXT/components/BlogPostListScroll.js | 2 +- themes/NEXT/components/Footer.js | 4 +- themes/NEXT/components/InfoCard.js | 8 +- themes/NEXT/components/LatestPostsGroup.js | 4 +- themes/NEXT/components/Logo.js | 4 +- themes/NEXT/components/PaginationNumber.js | 2 +- themes/NEXT/components/PaginationSimple.js | 2 +- themes/NEXT/components/ShareBar.js | 2 +- themes/NEXT/components/SideAreaLeft.js | 2 +- themes/NEXT/components/SocialButton.js | 10 +- 54 files changed, 284 insertions(+), 247 deletions(-) rename {themes/NEXT/components => components}/Tabs.js (100%) diff --git a/blog.config.js b/blog.config.js index 80bce8f68d8..bfdcc9ff6c9 100644 --- a/blog.config.js +++ b/blog.config.js @@ -1,73 +1,108 @@ -const BLOG = { - title: '小唐笔记', // 站点标题 - description: '分享编程技术与记录生活', // 站点描述 - author: 'tangly1024', // 作者 - bio: '一个普通的干饭人🍚', // 作者简介 - email: 'tlyong1992@hotmail.com', // 联系邮箱 - link: 'https://tangly1024.com', // 网站地址 - keywords: ['Notion', '写作', '博客'], // 网站关键词 - lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more. - beian: '闽ICP备20010331号', // 备案号 - notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // Important page_id!!! - notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public - appearance: 'auto', // ['light', 'dark', 'auto'], - font: 'font-serif tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family - lightBackground: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc - darkBackground: '#111827', // use hex value, don't forget '#' - path: '', // leave this empty unless you want to deploy in a folder - since: 2020, // if leave this empty, current year will be used. - postListStyle: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载 - postsPerPage: 6, // post counts per page - previewLines: 12, // 预览博客行数 - sortByDate: false, - socialLink: { // 社交链接,如不需要展示可以留空白,例如 weibo:'' - weibo: 'https://weibo.com/tangly1024', - twitter: 'https://twitter.com/troy1024_1', - github: 'https://github.com/tangly1024', - telegram: 'https://t.me/tangly_1024' - }, - comment: { // 评论插件,支持 gitalk, utterances, cusdis - provider: 'gitalk', // 不需要则留空白 - gitalkConfig: { - repo: 'NotionNext', // The repository of store comments - owner: 'tangly1024', - admin: ['tangly1024'], - clientID: process.env.GITALK_ID || 'be7864a16b693e256f8f', - clientSecret: process.env.GITALK_SECRET || 'dbd0f6d9ceea8940f6ed20936b415274b8fe66a2', - distractionFreeMode: false - }, - cusdisConfig: { - appId: '445ba48e-f751-487f-b22f-cdbe3310d28f', // data-app-id - host: 'https://cusdis.com', // data-host, change this if you're using self-hosted version - scriptSrc: 'https://cusdis.com/js/cusdis.es.js' // change this if you're using self-hosted version - }, - utterancesConfig: { - repo: 'tangly1024/NotionNext' - }, - gitter: '', // gitter聊天室 - DaoVoiceId: '', // DaoVoice http://dashboard.daovoice.io/get-started - TidioId: '' // https://www.tidio.com/ - }, - // --- 高级设置 - analytics: { // 文章访问量统计 - busuanzi: true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ - provider: 'ga', // 支持 Google Analytics and Ackee, please fill with 'ga' or 'ackee', leave it empty to disable it. - baiduAnalytics: 'f683ef76f06bb187cbed5546f6f28f28', // e.g only need xxxxx -> https://hm.baidu.com/hm.js?[xxxxx] - cnzzAnalytics: '', // 站长统计id only need xxxxxxxx -> https://s9.cnzz.com/z_stat.php?id=[xxxxxxxx]&web_id=[xxxxxxx] - gaConfig: { - measurementId: 'G-68EK0W049N' // e.g: G-XXXXXXXXXX - }, - ackeeConfig: { - tracker: '', // e.g 'https://ackee.tangly1024.net/tracker.js' - dataAckeeServer: '', // e.g https://ackee.tangly1024.net , don't end with a slash - domainId: '' // e.g '0e2257a8-54d4-4847-91a1-0311ea48cc7b' - } - }, - seo: { - googleSiteVerification: '' // Remove the value or replace it with your own google site verification code - }, - googleAdsenseId: 'ca-pub-2708419466378217', // 谷歌广告ID +// 注: 配置文件可以读取Vercel的环境变量,配置方式参考:https://docs.tangly1024.com/zh/features/personality +const BLOG = mergeDeep(process.env, { + TITLE: 'NotionNext BLOG', // 站点标题 + DESCRIPTION: '这是一个由NotionNext生成的站点', // 站点描述 + AUTHOR: 'tangly1024', // 作者 + BIO: '一个普通的干饭人🍚', // 作者简介 + LINK: 'https://tangly1024.com', // 网站地址 + NOTION_PAGE_ID: '02ab3b8678004aa69e9e415905ef32a5', // Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5 + NOTION_ACCESS_TOKEN: '', // Useful if you prefer not to make your database public + KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开 + LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more. + BEI_AN: '', // 备案号 闽ICP备XXXXXXX + SINCE: 2020, // if leave this empty, current year will be used. + + APPEARANCE: 'auto', // ['light', 'dark', 'auto'], + FONT: 'font-serif tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family + BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc + BACKGROUND_DARK: '#111827', // use hex value, don't forget '#' + PATH: '', // leave this empty unless you want to deploy in a folder + + POST_LIST_STYLE: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载 + POST_PREVIEW_LINES: 12, // 预览博客行数 + POSTS_PER_PAGE: 6, // post counts per page + POSTS_SORT_BY_DATE: false, // 是否强制按时间排序,否则默认由notion排序文章 + + // 社交链接,不需要可留空白,例如 CONTACT_WEIBO:'' + CONTACT_EMAIL: 'tlyong1992@hotmail.com', // 联系邮箱 + CONTACT_WEIBO: 'https://weibo.com/tangly1024', + CONTACT_TWITTER: 'https://twitter.com/troy1024_1', + CONTACT_GITHUB: 'https://github.com/tangly1024', + CONTACT_TELEGRAM: 'https://t.me/tangly_1024', + + COMMENT_PROVIDER: '', // 支持 gitalk, utterances, cusdis + + COMMENT_GITALK_REPO: '', // e.g NotionNext + COMMENT_GITALK_OWNER: '', // e.g tangly1024 + COMMENT_GITALK_ADMIN: '', // e.g 'tangly1024' + COMMENT_GITALK_CLIENT_ID: '', + COMMENT_GITALK_CLIENT_SECRET: '', + COMMENT_GITALK_DISTRACTION_FREE_MODE: false, + + COMMENT_CUSDIS_APP_ID: '', // data-app-id + COMMENT_CUSDIS_HOST: 'https://cusdis.com', // data-host, change this if you're using self-hosted version + COMMENT_CUSDIS_SCRIPT_SRC: 'https://cusdis.com/js/cusdis.es.js', // change this if you're using self-hosted version + + COMMENT_UTTERRANCES_REPO: '', // e.g 'tangly1024/NotionNext' + + COMMENT_GITTER_ENABLE: false, // gitter see https://gitter.im/ + COMMENT_GITTER_ROOM: '', // gitter聊天室 + + COMMENT_DAO_VOICE_ENABLE: false, // DaoVoice see http://dashboard.daovoice.io/get-started + COMMENT_DAO_VOICE_ID: '', // DaoVoice http://dashboard.daovoice.io/get-started + + COMMENT_TIDIO_ENABLE: false, // https://www.tidio.com/ + COMMENT_TIDIO_ID: '', // [tidio_id] -> //code.tidio.co/[tidio_id].js + + // 站点统计 + + ANALYTICS_BUSUANZI_ENABLE: true, // 展示网站阅读量、访问数 see http://busuanzi.ibruce.info/ + + ANALYTICS_BAIDU_ENABLE: false, + ANALYTICS_BAIDU_ID: '', // e.g 只需要填写百度统计的id,[baidu_id] -> https://hm.baidu.com/hm.js?[baidu_id] + + ANALYTICS_CNZZ_ENABLE: false, + ANALYTICS_CNZZ_ID: '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id] + + ANALYTICS_GOOGLE_ENABLE: false, + ANALYTICS_GOOGLE_ID: '', // 谷歌Analytics的id e.g: G-XXXXXXXXXX + + ANALYTICS_ACKEE_ENABLE: false, + ANALYTICS_ACKEE_TRACKER: '', // e.g 'https://ackee.tangly1024.net/tracker.js' + ANALYTICS_ACKEE_DATA_SERVER: '', // e.g https://ackee.tangly1024.net , don't end with a slash + ANALYTICS_ACKEE_DOMAIN_ID: '', // e.g '0e2257a8-54d4-4847-91a1-0311ea48cc7b' + + SEO_GOOGLE_SITE_VERIFICATION: '', // Remove the value or replace it with your own google site verification code + + GOOGLE_ADSENSE_ENABLE: false, + GOOGLE_ADSENSE_ID: process.env.GOOGLE_AD_ID, // 谷歌广告ID isProd: process.env.VERCEL_ENV === 'production'// distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) +}) + +/** + * 深度合并两个对象 + * @param target + * @param sources + */ +function mergeDeep (target, ...sources) { + if (!sources.length) return target + const source = sources.shift() + + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!target[key]) Object.assign(target, { [key]: {} }) + mergeDeep(target[key], source[key]) + } else { + Object.assign(target, { [key]: source[key] }) + } + } + } + return mergeDeep(target, ...sources) +} + +function isObject (item) { + return (item && typeof item === 'object' && !Array.isArray(item)) } -// export default BLOG + module.exports = BLOG diff --git a/components/Ackee.js b/components/Ackee.js index 45d14d7a22c..9813c1699b7 100644 --- a/components/Ackee.js +++ b/components/Ackee.js @@ -1,12 +1,21 @@ import { useRouter } from 'next/router' import useAckee from 'use-ackee' +import BLOG from '@/blog.config' -const Ackee = ({ ackeeServerUrl, ackeeDomainId }) => { +const Ackee = () => { + const ackeeServerUrl = BLOG.ANALYTICS_ACKEE_DATA_SERVER + const ackeeDomainId = BLOG.ANALYTICS_ACKEE_DOMAIN_ID const router = useRouter() useAckee( router.asPath, - { server: ackeeServerUrl, domainId: ackeeDomainId }, - { detailed: false, ignoreLocalhost: true } + { + server: ackeeServerUrl, + domainId: ackeeDomainId + }, + { + detailed: false, + ignoreLocalhost: true + } ) return null } diff --git a/components/Comment.js b/components/Comment.js index 5e49f4d3692..4aed200785c 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -3,6 +3,7 @@ import dynamic from 'next/dynamic' import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' import 'gitalk/dist/gitalk.css' +import Tabs from '@/components/Tabs' const GitalkComponent = dynamic( () => { @@ -28,44 +29,44 @@ const Comment = ({ frontMatter }) => { const { theme } = useGlobal() return ( - BLOG.comment.provider !== '' && ( -
- {BLOG.comment.provider === 'gitalk' && (
+
+ + {BLOG.COMMENT_GITALK_CLIENT_ID && (
)} - {BLOG.comment.provider === 'utterances' && (
- -
+ {BLOG.COMMENT_UTTERRANCES_REPO && (
+ +
)} - {BLOG.comment.provider === 'cusdis' && (<> + {BLOG.COMMENT_CUSDIS_APP_ID && (<> +