From 05d79a3db953682446794269878f09264367e09d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 11 Oct 2021 17:14:52 +0800 Subject: [PATCH 001/389] =?UTF-8?q?4.0=20=E4=BB=BFYoutube=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DarkModeButton.js | 2 +- components/Footer.js | 6 +- components/Header.js | 49 ++++---- components/{TopJumper.js => JumpToTop.js} | 7 +- components/LeftFloatButton.js | 42 +++++++ components/Logo.js | 11 ++ components/Pagination.js | 7 ++ components/Progress.js | 2 +- components/RewardButton.js | 2 +- components/RightAside.js | 11 +- components/RightWidget.js | 11 -- components/SideBar.js | 134 ---------------------- components/SideBarEmbed.js | 67 +++++++++++ components/SideBarResponsive.js | 67 +++++++++++ components/SocialButton.js | 12 +- components/Tags.js | 18 ++- components/TocBar.js | 9 +- components/TopNav.js | 89 +++++++++----- components/Utterances.js | 12 +- layouts/ArticleLayout.js | 13 ++- layouts/DefaultLayout.js | 109 +++++++----------- styles/globals.css | 11 +- 22 files changed, 391 insertions(+), 300 deletions(-) rename components/{TopJumper.js => JumpToTop.js} (89%) create mode 100644 components/LeftFloatButton.js create mode 100644 components/Logo.js delete mode 100644 components/RightWidget.js delete mode 100644 components/SideBar.js create mode 100644 components/SideBarEmbed.js create mode 100644 components/SideBarResponsive.js diff --git a/components/DarkModeButton.js b/components/DarkModeButton.js index 6c3adfdc..796abce3 100644 --- a/components/DarkModeButton.js +++ b/components/DarkModeButton.js @@ -8,7 +8,7 @@ const DarkModeButton = () => { changeTheme(newTheme) localStorage.setItem('theme', newTheme) } - return
+ return
} diff --git a/components/Footer.js b/components/Footer.js index 3b135f0e..c36db071 100644 --- a/components/Footer.js +++ b/components/Footer.js @@ -4,15 +4,13 @@ import React from 'react' const Footer = ({ fullWidth = true }) => { const d = new Date() const y = d.getFullYear() - const from = +BLOG.since return ( ) } diff --git a/components/SideBar.js b/components/SideBar.js index 384b9880..cd1797ba 100644 --- a/components/SideBar.js +++ b/components/SideBar.js @@ -23,9 +23,10 @@ import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/fr * @returns {JSX.Element} * @constructor */ -const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => { +const SideBar = ({ title, tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => { const { locale } = useGlobal() return
{post && post.toc && post.toc.length > 1 && ( diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 24bf33ae..045b5abd 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache' const enableCache = true // 生产环境禁用 diff --git a/lib/cache/memory_cache.js b/lib/cache/memory_cache.js index ce107e0c..973225a0 100644 --- a/lib/cache/memory_cache.js +++ b/lib/cache/memory_cache.js @@ -1,9 +1,12 @@ import cache from 'memory-cache' +import BLOG from 'blog.config' + +const cacheTime = BLOG.isProd ? 60 : 60 * 60 export async function getCacheFromMemory (key, options) { return cache.get(key) } export async function setCacheToMemory (key, data) { - await cache.put(key, data, 60 * 1000) // 1 minutes + await cache.put(key, data, cacheTime * 1000) } From 2b47ff626c0033f36b9f0e11c4779826eb1c8edb Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 17 Dec 2021 21:25:58 +0800 Subject: [PATCH 196/389] Adsense --- components/SideArea.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/SideArea.js b/components/SideArea.js index d39b160a..9d9e4473 100644 --- a/components/SideArea.js +++ b/components/SideArea.js @@ -52,6 +52,17 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat )} +
+ {/* 展示广告 */} + +
+ {/* 分类 */} {categories && (
@@ -83,17 +94,6 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat
)} - -
- {/* 展示广告 */} - -
{post && post.toc && post.toc.length > 1 && ( From 44121bf50bc98957d63fa0bb0037139d544cff9e Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 20 Dec 2021 11:30:38 +0800 Subject: [PATCH 197/389] =?UTF-8?q?feature:=20=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ArticleDetail.js | 2 +- components/BlogPostListScroll.js | 2 +- components/SideArea.js | 11 ----------- components/Toc.js | 4 ++-- components/TocDrawer.js | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/components/ArticleDetail.js b/components/ArticleDetail.js index 56534a49..aeb733ee 100644 --- a/components/ArticleDetail.js +++ b/components/ArticleDetail.js @@ -44,7 +44,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n return (<>
{post.type && !post.type.includes('Page') && post?.page_cover && ( diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js index 7b85dad3..29a86a47 100644 --- a/components/BlogPostListScroll.js +++ b/components/BlogPostListScroll.js @@ -33,7 +33,7 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory, const scrollTrigger = useCallback(throttle(() => { const scrollS = window.scrollY + window.outerHeight const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0 - if (scrollS > clientHeight + 10) { + if (scrollS > clientHeight + 100) { handleGetMore() } }, 500)) diff --git a/components/SideArea.js b/components/SideArea.js index 9d9e4473..0766d359 100644 --- a/components/SideArea.js +++ b/components/SideArea.js @@ -52,17 +52,6 @@ const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCat )} -
- {/* 展示广告 */} - -
- {/* 分类 */} {categories && (
diff --git a/components/Toc.js b/components/Toc.js index 9665c175..55c640e1 100644 --- a/components/Toc.js +++ b/components/Toc.js @@ -51,14 +51,14 @@ const Toc = ({ toc }) => { }, throttleMs)) return <> -
@@ -181,7 +178,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
{/* 评论互动 */} -
+
@@ -199,42 +196,3 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n const mapPageUrl = id => { return 'https://www.notion.so/' + id.replace(/-/g, '') } - -/** - * 更新字数统计和阅读时间 - */ -function countWords () { - if (window) { - const articleElement = document.getElementById('notion-article') - if (articleElement) { - const articleText = deleteHtmlTag(articleElement.innerHTML) - const wordCount = fnGetCpmisWords(articleText) - // 阅读速度 300-500每分钟 - document.getElementById('wordCount').innerHTML = wordCount - document.getElementById('readTime').innerHTML = Math.floor(wordCount / 400) - } - } -} - -// 去除html标签 -function deleteHtmlTag (str) { - str = str.replace(/<[^>]+>|&[^>]+;/g, '').trim()// 去掉所有的html标签和 之类的特殊符合 - return str -} - -// 用word方式计算正文字数 -function fnGetCpmisWords (str) { - let sLen = 0 - try { - // eslint-disable-next-line no-irregular-whitespace - str = str.replace(/(\r\n+|\s+| +)/g, '龘') - // eslint-disable-next-line no-control-regex - str = str.replace(/[\x00-\xff]/g, 'm') - str = str.replace(/m+/g, '*') - str = str.replace(/龘+/g, '') - sLen = str.length - } catch (e) { - - } - return sLen -} diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js index 05a7ced7..2a1f5dbf 100644 --- a/components/BlogPostCard.js +++ b/components/BlogPostCard.js @@ -8,7 +8,7 @@ import TagItemMini from './TagItemMini' const BlogPostCard = ({ post, tags }) => { return ( -
@@ -41,8 +41,8 @@ const BlogPostCard = ({ post, tags }) => { {post?.page_cover && ( -
- {post.title} +
+ {post.title}
)} diff --git a/components/BlogPostListScroll.js b/components/BlogPostListScroll.js index 29a86a47..351c4927 100644 --- a/components/BlogPostListScroll.js +++ b/components/BlogPostListScroll.js @@ -64,7 +64,7 @@ const BlogPostListScroll = ({ posts = [], tags, currentSearch, currentCategory,
{ handleGetMore() }} - className='w-full my-4 py-4 text-center cursor-pointer glassmorphism dark:text-gray-200' + className='w-full my-4 py-4 text-center cursor-pointer glassmorphism shadow-xl rounded-xl dark:text-gray-200' > {hasMore ? '继续加载' : '加载完了😰'}
diff --git a/components/CategoryGroup.js b/components/CategoryGroup.js index b21547ce..7c2759bb 100644 --- a/components/CategoryGroup.js +++ b/components/CategoryGroup.js @@ -10,9 +10,9 @@ const CategoryGroup = ({ currentCategory, categories }) => { const selected = currentCategory === category return
+ ' rounded-xl text-md w-full items-center duration-300 dark:hover:text-blue-400 hover:underline px-3 mx-2 cursor-pointer py-2 font-light'}> {category}({categories[category]}) diff --git a/components/FloatDarkModeButton.js b/components/FloatDarkModeButton.js index a22abdf2..e09b79c3 100644 --- a/components/FloatDarkModeButton.js +++ b/components/FloatDarkModeButton.js @@ -32,7 +32,7 @@ export default function FloatDarkModeButton () { onClick={handleChangeDarkMode} className={ (show ? 'animate__fadeInRight ' : 'hidden lg:block') + - ' px-3.5 py-3 animate__animated animate__faster shadow-card fixed right-5 bottom-36 z-10 duration-200 text-xs cursor-pointer rounded-xl' + + ' px-3.5 py-3 animate__animated animate__faster shadow-card fixed right-3 bottom-36 z-10 duration-200 text-xs cursor-pointer rounded-xl' + ' text-black shadow-card dark:border-gray-500 glassmorphism dark:bg-gray-700 dark:text-gray-200' } > diff --git a/components/JumpToTopButton.js b/components/JumpToTopButton.js index 9297da01..792d9c93 100644 --- a/components/JumpToTopButton.js +++ b/components/JumpToTopButton.js @@ -37,7 +37,7 @@ const JumpToTopButton = ({ targetRef, showPercent = true }) => { return () => document.removeEventListener('scroll', scrollListener) }, [show]) - return (
+ return (
window.scrollTo({ top: 0, behavior: 'smooth' })} className={(show ? '' : 'hidden') + ' animate__fadeInRight animate__animated animate__faster shadow-card rounded-xl glassmorphism py-1 cursor-pointer '}>
diff --git a/components/LatestPostsGroup.js b/components/LatestPostsGroup.js index c254b93b..5ead6bd2 100644 --- a/components/LatestPostsGroup.js +++ b/components/LatestPostsGroup.js @@ -1,6 +1,7 @@ -import Link from 'next/link' import BLOG from '@/blog.config' -import { formatDateFmt } from '@/lib/formatDate' +import { faFileAlt } from '@fortawesome/free-solid-svg-icons' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import Link from 'next/link' import { useRouter } from 'next/router' /** @@ -32,13 +33,11 @@ const LatestPostsGroup = ({ posts, sliceCount = 5 }) => { return ( -
+ {post.title}
-
- {formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')} -
) diff --git a/components/LoadingCover.js b/components/LoadingCover.js index 2eacf0c6..1bbc0de1 100644 --- a/components/LoadingCover.js +++ b/components/LoadingCover.js @@ -2,7 +2,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faSpinner } from '@fortawesome/free-solid-svg-icons' export default function LoadingCover () { - return (
+ return (
diff --git a/components/MenuButtonGroup.js b/components/MenuButtonGroup.js index f564c40a..d6736511 100644 --- a/components/MenuButtonGroup.js +++ b/components/MenuButtonGroup.js @@ -28,7 +28,7 @@ const MenuButtonGroup = ({ allowCollapse = false }) => { if (link.show) { const selected = (router.pathname === link.to) || (router.asPath === link.to) return -
diff --git a/components/SideArea.js b/components/SideArea.js index 0766d359..7f945890 100644 --- a/components/SideArea.js +++ b/components/SideArea.js @@ -1,15 +1,13 @@ -import React from 'react' -import MenuButtonGroup from '@/components/MenuButtonGroup' -import InfoCard from '@/components/InfoCard' -import TagGroups from '@/components/TagGroups' -import LatestPostsGroup from '@/components/LatestPostsGroup' import CategoryGroup from '@/components/CategoryGroup' +import InfoCard from '@/components/InfoCard' +import MenuButtonGroup from '@/components/MenuButtonGroup' import SearchInput from '@/components/SearchInput' -import Link from 'next/link' -import { useGlobal } from '@/lib/global' import Toc from '@/components/Toc' +import { useGlobal } from '@/lib/global' +import { faAngleDoubleRight, faThList } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/free-solid-svg-icons' +import Link from 'next/link' +import React from 'react' /** * 侧边平铺 @@ -26,36 +24,26 @@ import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/fr const SideArea = ({ title, tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => { const { locale } = useGlobal() - return } diff --git a/components/SideAreaRight.js b/components/SideAreaRight.js index 87aa39e8..fb76fb09 100644 --- a/components/SideAreaRight.js +++ b/components/SideAreaRight.js @@ -1,9 +1,10 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' -import { faAngleDoubleRight, faAngleRight, faTags, faThList } from '@fortawesome/free-solid-svg-icons' +import { faAngleDoubleRight, faAngleRight, faTag, faThList } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Link from 'next/link' import React from 'react' +import Card from './Card' import CategoryGroup from './CategoryGroup' import TagGroups from './TagGroups' @@ -38,25 +39,25 @@ const SideAreaRight = ({ return (