Skip to content

Commit

Permalink
og:image完善
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed May 18, 2022
1 parent a3f2494 commit 0c844c4
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/CommonHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ThemeComponents.Layout404 {...props} meta={meta}/>
}

Expand Down
1 change: 1 addition & 0 deletions pages/archive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
5 changes: 2 additions & 3 deletions pages/article/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 <ThemeComponents.LayoutSlug {...props} showArticleInfo={true} meta={meta} />
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions pages/category/[category].js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function Category(props) {
}`,
description: siteInfo?.description,
slug: 'category/' + props.category,
image: siteInfo?.pageCover,
type: 'website'
}
return <ThemeComponents.LayoutCategory {...props} meta={meta} />
Expand Down
1 change: 1 addition & 0 deletions pages/category/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions pages/page/[page].js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions pages/search/[keyword].js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions pages/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Search = props => {
siteInfo?.title
}`,
description: siteInfo?.description,
image: siteInfo?.pageCover,
slug: 'search',
type: 'website'
}
Expand Down
1 change: 1 addition & 0 deletions pages/tag/[tag].js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions pages/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
2 changes: 1 addition & 1 deletion themes/hexo/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const LayoutBase = props => {

return (
<div className="bg-hexo-background-gray dark:bg-black">
<CommonHead meta={meta} />
<CommonHead meta={meta} siteInfo={siteInfo}/>

<TopNav {...props} />

Expand Down

0 comments on commit 0c844c4

Please sign in to comment.