mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 07:26:46 +00:00
Merge pull request #152 from txs/feature_better_head_and_seo_for_facebook_open_graph
Better SEO for Facebook Open Graph
This commit is contained in:
@@ -9,7 +9,7 @@ const BLOG = {
|
|||||||
process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', // Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5
|
process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', // Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5
|
||||||
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
|
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
|
||||||
DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮
|
DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮
|
||||||
|
FACEBOOK_PAGE: 'https://www.facebook.com/tw.andys.pro', // Facebook Page 的連結
|
||||||
THEME: process.env.NEXT_PUBLIC_THEME || 'next', // 主题, 支持 ['next','hexo',"fukasawa','medium']
|
THEME: process.env.NEXT_PUBLIC_THEME || 'next', // 主题, 支持 ['next','hexo',"fukasawa','medium']
|
||||||
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
|
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
|
||||||
LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
|
LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ const CommonHead = ({ meta, children }) => {
|
|||||||
const description = meta?.description || BLOG.DESCRIPTION
|
const description = meta?.description || BLOG.DESCRIPTION
|
||||||
const type = meta?.type || 'website'
|
const type = meta?.type || 'website'
|
||||||
const keywords = meta?.tags || BLOG.KEYWORDS
|
const keywords = meta?.tags || BLOG.KEYWORDS
|
||||||
|
const lang = BLOG.LANG.replace('-', '_') //Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言
|
||||||
|
const category = meta?.category || BLOG.KEYWORDS || '軟體科技' //section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Head>
|
<Head>
|
||||||
@@ -31,11 +33,12 @@ const CommonHead = ({ meta, children }) => {
|
|||||||
)}
|
)}
|
||||||
<meta name="keywords" content={keywords} />
|
<meta name="keywords" content={keywords} />
|
||||||
<meta name="description" content={description} />
|
<meta name="description" content={description} />
|
||||||
<meta property="og:locale" content={BLOG.LANG} />
|
<meta property="og:locale" content={lang} />
|
||||||
<meta property="og:title" content={title} />
|
<meta property="og:title" content={title} />
|
||||||
<meta property="og:description" content={description} />
|
<meta property="og:description" content={description} />
|
||||||
<meta property="og:url" content={url} />
|
<meta property="og:url" content={url} />
|
||||||
<meta property="og:image" content={image} />
|
<meta property="og:image" content={image} />
|
||||||
|
<meta property="og:site_name" content={BLOG.TITLE} />
|
||||||
<meta property="og:type" content={type} />
|
<meta property="og:type" content={type} />
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:description" content={description} />
|
<meta name="twitter:description" content={description} />
|
||||||
@@ -50,6 +53,8 @@ const CommonHead = ({ meta, children }) => {
|
|||||||
content={meta.date || meta.createdTime}
|
content={meta.date || meta.createdTime}
|
||||||
/>
|
/>
|
||||||
<meta property="article:author" content={BLOG.AUTHOR} />
|
<meta property="article:author" content={BLOG.AUTHOR} />
|
||||||
|
<meta property="article:section" content={category} />
|
||||||
|
<meta property="article:publisher" content={BLOG.FACEBOOK_PAGE} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ const Slug = props => {
|
|||||||
type: 'article',
|
type: 'article',
|
||||||
slug: 'article/' + props.post.slug,
|
slug: 'article/' + props.post.slug,
|
||||||
image: props.post.page_cover,
|
image: props.post.page_cover,
|
||||||
|
category: props.post.category?.[0],
|
||||||
tags: props.post.tags
|
tags: props.post.tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user