From 0c844c498680b20e4ae39c1fad3044f9ef83a8f9 Mon Sep 17 00:00:00 2001 From: tlyong1992 Date: Wed, 18 May 2022 14:21:13 +0800 Subject: [PATCH] =?UTF-8?q?og:image=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CommonHead.js | 2 +- pages/404.js | 4 ++-- pages/archive/index.js | 1 + pages/article/[slug].js | 5 ++--- pages/category/[category].js | 1 + pages/category/index.js | 1 + pages/page/[page].js | 1 + pages/search/[keyword].js | 1 + pages/search/index.js | 1 + pages/tag/[tag].js | 1 + pages/tag/index.js | 1 + themes/hexo/LayoutBase.js | 2 +- 12 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/CommonHead.js b/components/CommonHead.js index 7f129995..f4fe840a 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -6,7 +6,7 @@ const CommonHead = ({ meta, children }) => { let image if (meta) { url = `${url}/${meta.slug}` - image = meta.image || '' + image = meta.image || '/bg_image.jpg' } const title = meta?.title || BLOG.TITLE const description = meta?.description || BLOG.DESCRIPTION diff --git a/pages/404.js b/pages/404.js index b5a3ca8d..43172bfb 100644 --- a/pages/404.js +++ b/pages/404.js @@ -8,9 +8,9 @@ import { useGlobal } from '@/lib/global' * @returns */ const NoFound = props => { - const { theme } = useGlobal() + const { theme, siteInfo } = useGlobal() const ThemeComponents = ThemeMap[theme] - const meta = { title: `${props?.siteInfo?.title} | 页面找不到啦` } + const meta = { title: `${props?.siteInfo?.title} | 页面找不到啦`, image: siteInfo?.pageCover } return } diff --git a/pages/archive/index.js b/pages/archive/index.js index e66b2abd..fda51dc5 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -10,6 +10,7 @@ const ArchiveIndex = props => { const meta = { title: `${locale.NAV.ARCHIVE} | ${siteInfo?.title}`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'archive', type: 'website' } diff --git a/pages/article/[slug].js b/pages/article/[slug].js index 52a2082d..89a42833 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -15,7 +15,7 @@ import { useRouter } from 'next/router' const Slug = props => { const { theme, changeLoadingState } = useGlobal() const ThemeComponents = ThemeMap[theme] - const { post } = props + const { post, siteInfo } = props if (!post) { changeLoadingState(true) @@ -30,7 +30,7 @@ const Slug = props => { } } }, 10000) - const meta = { title: `${props?.siteInfo?.title || BLOG.TITLE} | loading` } + const meta = { title: `${props?.siteInfo?.title || BLOG.TITLE} | loading`, image: siteInfo?.pageCover } return } @@ -58,7 +58,6 @@ const Slug = props => { props = { ...props, lock, setLock, validPassword } - const { siteInfo } = props const meta = { title: `${post?.title} | ${siteInfo?.title}`, description: post?.summary, diff --git a/pages/category/[category].js b/pages/category/[category].js index 80281a01..ac44bb05 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -17,6 +17,7 @@ export default function Category(props) { }`, description: siteInfo?.description, slug: 'category/' + props.category, + image: siteInfo?.pageCover, type: 'website' } return diff --git a/pages/category/index.js b/pages/category/index.js index f099d29f..13f95eee 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -11,6 +11,7 @@ export default function Category(props) { const meta = { title: `${locale.COMMON.CATEGORY} | ${siteInfo?.title}`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'category', type: 'website' } diff --git a/pages/page/[page].js b/pages/page/[page].js index b6787758..f86b0902 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -14,6 +14,7 @@ const Page = props => { const meta = { title: `${props.page} | Page | ${siteInfo?.title}`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'page/' + props.page, type: 'website' } diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 1607cb90..03fb8109 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -10,6 +10,7 @@ const Index = props => { const meta = { title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, description: siteInfo?.title, + image: siteInfo?.pageCover, slug: 'search/' + (keyword || ''), type: 'website' } diff --git a/pages/search/index.js b/pages/search/index.js index 80cfe52c..30e97c95 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -26,6 +26,7 @@ const Search = props => { siteInfo?.title }`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'search', type: 'website' } diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index be89d2fa..121dc973 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -15,6 +15,7 @@ const Tag = props => { const meta = { title: `${tag} | ${locale.COMMON.TAGS} | ${siteInfo?.title}`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'tag/' + tag, type: 'website' } diff --git a/pages/tag/index.js b/pages/tag/index.js index 302511dc..1ceb0f07 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -11,6 +11,7 @@ const TagIndex = props => { const meta = { title: `${locale.COMMON.TAGS} | ${siteInfo?.title}`, description: siteInfo?.description, + image: siteInfo?.pageCover, slug: 'tag', type: 'website' } diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index c8ca3f8a..ff45d646 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -53,7 +53,7 @@ const LayoutBase = props => { return (
- +