From 67506c4644698ae41819ce8dcd1aaa70035a6256 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 14:50:20 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blog.config.js b/blog.config.js index 90df2948..c19986fe 100644 --- a/blog.config.js +++ b/blog.config.js @@ -120,7 +120,7 @@ const BLOG = { process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖 isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) - VERSION: '3.1.0' // 版本号 + VERSION: '3.2.0' // 版本号 } module.exports = BLOG diff --git a/package.json b/package.json index d47bdc78..8099bf59 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.1.0", + "version": "3.2.0", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { From a23810fa59d9f5dce43653cf0bf89c95ed71a258 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 14:54:58 +0800 Subject: [PATCH 02/16] build --- themes/example/LayoutSearch.js | 2 +- themes/fukasawa/LayoutSearch.js | 5 ++--- themes/fukasawa/components/BlogListPage.js | 4 ++-- themes/hexo/LayoutSearch.js | 6 +++--- themes/medium/components/BlogPostListScroll.js | 8 ++++---- themes/medium/components/CategoryGroup.js | 4 ++-- themes/medium/components/TagGroups.js | 12 ++++++------ 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/themes/example/LayoutSearch.js b/themes/example/LayoutSearch.js index d24024a5..110c11a6 100644 --- a/themes/example/LayoutSearch.js +++ b/themes/example/LayoutSearch.js @@ -38,7 +38,7 @@ export const LayoutSearch = props => {

Search - {keyword}

- {postsToShow.map(p => ( + {postsToShow?.map(p => (
{p.title} diff --git a/themes/fukasawa/LayoutSearch.js b/themes/fukasawa/LayoutSearch.js index 727e9595..46d01031 100644 --- a/themes/fukasawa/LayoutSearch.js +++ b/themes/fukasawa/LayoutSearch.js @@ -14,10 +14,9 @@ export const LayoutSearch = (props) => { const re = new RegExp(`${currentSearch}`, 'gim') container.innerHTML = container.innerHTML.replace(re, `${currentSearch}`) } - }, - 100) + }, 100) }) return - + } diff --git a/themes/fukasawa/components/BlogListPage.js b/themes/fukasawa/components/BlogListPage.js index 51c1c6c1..a418ff47 100644 --- a/themes/fukasawa/components/BlogListPage.js +++ b/themes/fukasawa/components/BlogListPage.js @@ -17,7 +17,7 @@ const BlogListPage = ({ page = 1, posts = [], postCount }) => { const showNext = page < totalPage && posts.length === BLOG.POSTS_PER_PAGE && posts.length < postCount const [colCount, changeCol] = useState(1) - function updateCol () { + function updateCol() { if (window.outerWidth > 1200) { changeCol(3) } else { @@ -40,7 +40,7 @@ const BlogListPage = ({ page = 1, posts = [], postCount }) => {
{/* 文章列表 */}
- {posts.map(post => ( + {posts?.map(post => (
diff --git a/themes/hexo/LayoutSearch.js b/themes/hexo/LayoutSearch.js index 9b0803ec..6152a282 100644 --- a/themes/hexo/LayoutSearch.js +++ b/themes/hexo/LayoutSearch.js @@ -27,7 +27,7 @@ export const LayoutSearch = props => { const re = new RegExp(`${currentSearch}`, 'gim') container.innerHTML = container.innerHTML.replace( re, - `${currentSearch}` + `${currentSearch}` ) handleTextColor = true } @@ -46,7 +46,7 @@ export const LayoutSearch = props => { {locale.COMMON.CATEGORY}:
- {categories.map(category => { + {categories?.map(category => { return ( { {locale.COMMON.TAGS}:
- {tags.map(tag => { + {tags?.map(tag => { return (
diff --git a/themes/medium/components/BlogPostListScroll.js b/themes/medium/components/BlogPostListScroll.js index 1b2334cc..3b2003df 100644 --- a/themes/medium/components/BlogPostListScroll.js +++ b/themes/medium/components/BlogPostListScroll.js @@ -65,8 +65,8 @@ const BlogPostListScroll = ({ posts = [], currentSearch }) => { {/* 文章列表 */}
- {postsToShow.map(post => ( - + {postsToShow?.map(post => ( + ))}
@@ -74,7 +74,7 @@ const BlogPostListScroll = ({ posts = [], currentSearch }) => {
{ handleGetMore() }} - className='w-full my-4 py-4 text-center cursor-pointer glassmorphism shadow-xl rounded-xl 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 ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}
@@ -95,7 +95,7 @@ const getPostByPage = function (page, totalPosts, postsPerPage) { ) } -function getSearchKey () { +function getSearchKey() { const router = useRouter() if (router.query && router.query.s) { return router.query.s diff --git a/themes/medium/components/CategoryGroup.js b/themes/medium/components/CategoryGroup.js index 797e3afa..12b41e0f 100644 --- a/themes/medium/components/CategoryGroup.js +++ b/themes/medium/components/CategoryGroup.js @@ -8,9 +8,9 @@ const CategoryGroup = ({ currentCategory, categories }) => { return
分类
- {categories.map(category => { + {categories?.map(category => { const selected = currentCategory === category.name - return + return })}
diff --git a/themes/medium/components/TagGroups.js b/themes/medium/components/TagGroups.js index dd2a2643..9168fa20 100644 --- a/themes/medium/components/TagGroups.js +++ b/themes/medium/components/TagGroups.js @@ -13,12 +13,12 @@ const TagGroups = ({ tags, currentTag }) => {
标签
- { - tags.map(tag => { - const selected = tag.name === currentTag - return - }) - } + { + tags?.map(tag => { + const selected = tag.name === currentTag + return + }) + }
) From 11ff50076311b2077a725f29d34bcb1a7bc8123d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 15:05:47 +0800 Subject: [PATCH 03/16] =?UTF-8?q?hexo=E6=9F=A5=E8=AF=A2=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/BlogPostCard.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index 54a37a72..ab341356 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -38,13 +38,22 @@ const BlogPostCard = ({ post, showSummary }) => {
- {(!showPreview || showSummary) && ( + {(!showPreview || showSummary) && !post.results && (

{post.summary}

)} + {/* 搜索结果 */} + {post.results && ( +

+ {post.results.map(r => ( + {r} + ))} +

+ )} + {showPreview && (
From 15ef58a8547ae6cf7b6aa889a8889cb28a105600 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 15:20:24 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutSearch.js | 4 +--- themes/hexo/components/BlogPostCard.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/themes/hexo/LayoutSearch.js b/themes/hexo/LayoutSearch.js index 6152a282..9f003d2c 100644 --- a/themes/hexo/LayoutSearch.js +++ b/themes/hexo/LayoutSearch.js @@ -13,14 +13,13 @@ export const LayoutSearch = props => { const { locale } = useGlobal() const router = useRouter() const currentSearch = keyword || router?.query?.s - let handleTextColor = false const cRef = useRef(null) useEffect(() => { setTimeout(() => { // 自动聚焦到搜索框 cRef?.current?.focus() - if (currentSearch && !handleTextColor) { + if (currentSearch) { const targets = document.getElementsByClassName('replace') for (const container of targets) { if (container && container.innerHTML) { @@ -29,7 +28,6 @@ export const LayoutSearch = props => { re, `${currentSearch}` ) - handleTextColor = true } } } diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index ab341356..ea95f425 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -78,7 +78,7 @@ const BlogPostCard = ({ post, showSummary }) => {
- {CONFIG_HEXO.POST_LIST_COVER && !showPreview && post?.page_cover && ( + {CONFIG_HEXO.POST_LIST_COVER && !showPreview && post?.page_cover && !post.results && (
{/* eslint-disable-next-line @next/next/no-img-element */} From d802ed7c5f339c77e6bbb726dd2d0e469c3b5e03 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 19:44:51 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E8=B7=B3=E5=88=B0=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.js | 2 +- lib/rss.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 4295f224..0930eef4 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -59,7 +59,7 @@ const NotionPage = ({ post }) => { (zoomRef.current).attach(imgList[i]) } } - }, [router.events]) + }, [router?.events]) return
{ } const blockMap = await getPostBlocks(post.id, 'rss-content') if (blockMap) { + post.blockMap = blockMap const content = ReactDOMServer.renderToString() const regexExp = /
.*?<\/svg>
.*?<\/div><\/div>
.*?<\/div><\/div><\/div><\/div>/g return content.replace(regexExp, '') } - return post.summary } export async function generateRss(posts) { From 1e7b9e260a27b750aba2d1514d2a503e565ce823 Mon Sep 17 00:00:00 2001 From: txs Date: Mon, 18 Apr 2022 23:57:41 +0800 Subject: [PATCH 06/16] Add Facebook fanpage sidebar --- blog.config.js | 6 +++- components/FacebookPage.js | 27 ++++++++++++++++ package.json | 2 ++ themes/hexo/LayoutBase.js | 63 +++++++++++++++++++++++--------------- 4 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 components/FacebookPage.js diff --git a/blog.config.js b/blog.config.js index c19986fe..3a4a12b3 100644 --- a/blog.config.js +++ b/blog.config.js @@ -12,7 +12,11 @@ const BLOG = { FACEBOOK_PAGE_ID: process.env.NEXT_PUBLIC_FACEBOOK_PAGE_ID || '', // Facebook Page ID 來啟用 messenger 聊天功能 FACEBOOK_APP_ID: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID || '', // Facebook App ID 來啟用 messenger 聊天功能 - FACEBOOK_PAGE: process.env.NEXT_PUBLIC_FACEBOOK_PAGE || 'https://www.facebook.com/tw.andys.pro', // Facebook Page 的連結 + FACEBOOK_PAGE_TITLE: + process.env.NEXT_PUBLIC_FACEBOOK_PAGE_TITLE || 'FACEBOOK 粉絲團', // 邊欄 Facebook Page widget 的標題欄,填''則無標題欄 + FACEBOOK_PAGE: + process.env.NEXT_PUBLIC_FACEBOOK_PAGE || + 'https://www.facebook.com/tw.andys.pro', // Facebook Page 的連結 THEME: process.env.NEXT_PUBLIC_THEME || 'next', // 主题, 支持 ['next','hexo',"fukasawa','medium'] THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮 diff --git a/components/FacebookPage.js b/components/FacebookPage.js new file mode 100644 index 00000000..eda8a7df --- /dev/null +++ b/components/FacebookPage.js @@ -0,0 +1,27 @@ +import BLOG from '@/blog.config' +import { FacebookProvider, Page } from 'react-facebook' +import { FacebookIcon } from 'react-share' + +const FacebookPage = () => ( +
+ {BLOG.FACEBOOK_PAGE_TITLE && ( + + )} + + + +
+) +export default FacebookPage diff --git a/package.json b/package.json index 8099bf59..4b43b284 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,10 @@ "react-cookies": "^0.1.1", "react-cusdis": "^2.1.3", "react-dom": "17.0.2", + "react-facebook": "^8.1.4", "react-messenger-customer-chat": "^0.8.0", "react-notion-x": "6.6.2", + "react-share": "^4.4.0", "smoothscroll-polyfill": "^0.4.4", "typed.js": "^2.0.12", "use-ackee": "^3.0.0" diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 7b12a3f4..6d78abee 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -11,6 +11,7 @@ import Live2D from '@/components/Live2D' import LoadingCover from './components/LoadingCover' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' +import FacebookPage from '@/components/FacebookPage' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -18,11 +19,16 @@ import BLOG from '@/blog.config' * @returns {JSX.Element} * @constructor */ -const LayoutBase = (props) => { +const LayoutBase = props => { const { children, headerSlot, floatSlot, meta, siteInfo } = props const [show, switchShow] = useState(false) // const [percent, changePercent] = useState(0) // 页面阅读百分比 - const rightAreaSlot = + const rightAreaSlot = ( + <> + + + + ) const { onLoading } = useGlobal() const scrollListener = () => { @@ -30,7 +36,7 @@ const LayoutBase = (props) => { const clientHeight = targetRef?.clientHeight const scrollY = window.pageYOffset const fullHeight = clientHeight - window.outerHeight - let per = parseFloat(((scrollY / fullHeight * 100)).toFixed(0)) + let per = parseFloat(((scrollY / fullHeight) * 100).toFixed(0)) if (per > 100) per = 100 const shouldShow = scrollY > 100 && per > 0 @@ -45,37 +51,44 @@ const LayoutBase = (props) => { return () => document.removeEventListener('scroll', scrollListener) }, [show]) - return (
- + return ( +
+ - + - {headerSlot} + {headerSlot} -
+
+
+
+ {onLoading ? : children} +
-
-
- {onLoading ? : children} +
+
- + {/* 右下角悬浮 */} +
+
+ + {floatSlot} + +
-
- - {/* 右下角悬浮 */} -
-
- - {floatSlot} - -
+
- -
- -
) + ) } export default LayoutBase From ba9815030cdb1f3add84333edb5516ff1ba015e7 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Apr 2022 14:27:34 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9Craig=20Hart=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76fef972..169e221a 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ yarn run start # 本地启动NextJS服务 ## 致谢 感谢Craig Hart发起的Nobelium项目 - +
Craig Hart
Craig Hart
Craig Hart
Craig Hart
## 贡献者 From 59ad42b278d4cb88d7a1e38b96d3d929b22bf54c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 19 Apr 2022 14:34:51 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/fukasawa/components/Catalog.js | 12 ++++++------ themes/hexo/components/Catalog.js | 6 +++--- themes/medium/components/Catalog.js | 16 ++++++++-------- themes/next/components/Toc.js | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/themes/fukasawa/components/Catalog.js b/themes/fukasawa/components/Catalog.js index 2e67c392..cad8ce68 100644 --- a/themes/fukasawa/components/Catalog.js +++ b/themes/fukasawa/components/Catalog.js @@ -58,7 +58,7 @@ const Catalog = ({ toc }) => { return
目录
-
+