From 4315c5f81ca05925c636f90365682923eb194ce6 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 1 Feb 2024 21:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=85=AC=E5=85=B1Head?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/CommonHead.js | 73 --------- components/GlobalHead.js | 195 +++++++++++++++++++++++ lib/global.js | 2 +- pages/404.js | 5 - pages/[prefix]/index.js | 13 +- pages/_app.js | 3 + pages/archive/index.js | 14 -- pages/category/[category]/index.js | 16 -- pages/category/[category]/page/[page].js | 15 -- pages/category/index.js | 13 -- pages/index.js | 10 +- pages/page/[page].js | 12 -- pages/search/[keyword]/index.js | 14 -- pages/search/[keyword]/page/[page].js | 16 +- pages/search/index.js | 23 +-- pages/tag/[tag]/index.js | 13 -- pages/tag/[tag]/page/[page].js | 14 -- pages/tag/index.js | 14 -- themes/example/index.js | 6 +- themes/fukasawa/index.js | 5 +- themes/gitbook/index.js | 4 +- themes/heo/index.js | 7 +- themes/hexo/index.js | 5 +- themes/landing/index.js | 6 +- themes/matery/index.js | 6 +- themes/medium/index.js | 5 +- themes/nav/components/BlogPostItem.js | 2 +- themes/nav/components/MenuItem.js | 1 - themes/nav/index.js | 5 +- themes/next/index.js | 5 +- themes/nobelium/index.js | 7 +- themes/plog/index.js | 6 +- themes/simple/index.js | 6 +- 33 files changed, 226 insertions(+), 315 deletions(-) delete mode 100644 components/CommonHead.js create mode 100644 components/GlobalHead.js diff --git a/components/CommonHead.js b/components/CommonHead.js deleted file mode 100644 index 1aeb36dd..00000000 --- a/components/CommonHead.js +++ /dev/null @@ -1,73 +0,0 @@ -import { siteConfig } from '@/lib/config' -import Head from 'next/head' - -const CommonHead = ({ meta, children }) => { - let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` : siteConfig('LINK') - let image - if (meta) { - url = `${url}/${meta.slug}` - image = meta.image || '/bg_image.jpg' - } - const title = meta?.title || siteConfig('TITLE') - const description = meta?.description || siteConfig('DESCRIPTION') - const type = meta?.type || 'website' - const keywords = meta?.tags || siteConfig('KEYWORDS') - const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言 - const category = meta?.category || siteConfig('KEYWORDS') // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類 - - return ( - - {title} - - - - - {siteConfig('SEO_GOOGLE_SITE_VERIFICATION') && ( - - )} - {siteConfig('SEO_BAIDU_SITE_VERIFICATION') && ()} - - - - - - - - - - - - - - {siteConfig('COMMENT_WEBMENTION_ENABLE') && ( - <> - - - - )} - - {siteConfig('COMMENT_WEBMENTION_ENABLE') && siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && ( - - )} - - {JSON.parse(siteConfig('ANALYTICS_BUSUANZI_ENABLE')) && } - {meta?.type === 'Post' && ( - <> - - - - - - )} - {children} - - ) -} - -export default CommonHead diff --git a/components/GlobalHead.js b/components/GlobalHead.js new file mode 100644 index 00000000..92465d4a --- /dev/null +++ b/components/GlobalHead.js @@ -0,0 +1,195 @@ +import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import Head from 'next/head' +import { useRouter } from 'next/router' + +/** + * 页面的Head头,通常有用于SEO + * @param {*} param0 + * @returns + */ +const GlobalHead = (props) => { + const { children } = props + let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` : siteConfig('LINK') + let image + const meta = getSEOMeta(props, useRouter(), useGlobal()) + if (meta) { + url = `${url}/${meta.slug}` + image = meta.image || '/bg_image.jpg' + } + const title = meta?.title || siteConfig('TITLE') + const description = meta?.description || siteConfig('DESCRIPTION') + const type = meta?.type || 'website' + const keywords = meta?.tags || siteConfig('KEYWORDS') + const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言 + const category = meta?.category || siteConfig('KEYWORDS') // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類 + + return ( + + {title} + + + + + {siteConfig('SEO_GOOGLE_SITE_VERIFICATION') && ( + + )} + {siteConfig('SEO_BAIDU_SITE_VERIFICATION') && ()} + + + + + + + + + + + + + + {siteConfig('COMMENT_WEBMENTION_ENABLE') && ( + <> + + + + )} + + {siteConfig('COMMENT_WEBMENTION_ENABLE') && siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && ( + + )} + + {JSON.parse(siteConfig('ANALYTICS_BUSUANZI_ENABLE')) && } + {meta?.type === 'Post' && ( + <> + + + + + + )} + {children} + + ) +} + +/** + * 获取SEO信息 + * @param {*} props + * @param {*} router + */ +const getSEOMeta = (props, router, global) => { + console.log(props, router) + const { locale } = global + const { post, tag, category, page } = props + const keyword = router?.query?.s + + switch (router.route) { + case '/': + return { + title: `${siteConfig('TITLE')} | ${siteConfig('DESCRIPTION')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: '', + type: 'website' + } + case '/archive': + return { + title: `${locale.NAV.ARCHIVE} | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'archive', + type: 'website' + } + case '/page/[page]': + return { + title: `${page} | Page | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'page/' + page, + type: 'website' + } + case '/category/[category]': + return { + title: `${category} | ${locale.COMMON.CATEGORY} | ${ + siteConfig('TITLE') || '' + }`, + description: siteConfig('DESCRIPTION'), + slug: 'category/' + category, + image: siteConfig('HOME_BANNER_IMAGE'), + type: 'website' + } + case '/category/[category]/page/[page]': + return { + title: `${category} | ${locale.COMMON.CATEGORY} | ${ + siteConfig('TITLE') || '' + }`, + description: siteConfig('DESCRIPTION'), + slug: 'category/' + category, + image: siteConfig('HOME_BANNER_IMAGE'), + type: 'website' + } + case '/tag/[tag]': + case '/tag/[tag]/page/[page]': + return { + title: `${tag} | ${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'tag/' + tag, + type: 'website' + } + case '/search': + return { + title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'search', + type: 'website' + } + case '/search/[keyword]': + case '/search/[keyword]/page/[page]': + return { + title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, + description: siteConfig('TITLE'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'search/' + (keyword || ''), + type: 'website' + } + case '/404': + return { title: `${siteConfig('TITLE')} | 页面找不到啦`, image: siteConfig('HOME_BANNER_IMAGE') } + case '/tag': + return { + title: `${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'tag', + type: 'website' + } + case '/category': + return { + title: `${locale.COMMON.CATEGORY} | ${siteConfig('TITLE')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: 'category', + type: 'website' + } + default: + return { + title: post ? `${post?.title} | ${siteConfig('TITLE')}` : `${siteConfig('TITLE')} | loading`, + description: post?.summary, + type: post?.type, + slug: post?.slug, + image: post?.pageCoverThumbnail || siteConfig('HOME_BANNER_IMAGE'), + category: post?.category?.[0], + tags: post?.tags + } + } +} + +export default GlobalHead diff --git a/lib/global.js b/lib/global.js index 3346b4da..f1c84618 100644 --- a/lib/global.js +++ b/lib/global.js @@ -13,12 +13,12 @@ const GlobalContext = createContext() */ export function GlobalContextProvider(props) { const { post, children, siteInfo, categoryOptions, tagOptions, NOTION_CONFIG } = props - const router = useRouter() const [lang, updateLang] = useState(NOTION_CONFIG?.LANG || LANG) // 默认语言 const [locale, updateLocale] = useState(generateLocaleDict(NOTION_CONFIG?.LANG || LANG)) // 默认语言 const [theme, setTheme] = useState(NOTION_CONFIG?.THEME || THEME) // 默认博客主题 const [isDarkMode, updateDarkMode] = useState(NOTION_CONFIG?.APPEARANCE || APPEARANCE === 'dark') // 默认深色模式 const [onLoading, setOnLoading] = useState(false) // 抓取文章数据 + const router = useRouter() // 是否全屏 const fullWidth = post?.fullWidth ?? false diff --git a/pages/404.js b/pages/404.js index ae8eea37..49ec11df 100644 --- a/pages/404.js +++ b/pages/404.js @@ -9,13 +9,8 @@ import { siteConfig } from '@/lib/config' * @returns */ const NoFound = props => { - const meta = { title: `${siteConfig('TITLE')} | 页面找不到啦`, image: siteConfig('HOME_BANNER_IMAGE') } - - props = { ...props, meta } - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - return } diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js index dfc90fcc..036f585b 100644 --- a/pages/[prefix]/index.js +++ b/pages/[prefix]/index.js @@ -19,7 +19,7 @@ import { siteConfig } from '@/lib/config' * @returns */ const Slug = props => { - const { post, siteInfo } = props + const { post } = props const router = useRouter() // 文章锁🔐 @@ -66,16 +66,7 @@ const Slug = props => { } }, [post]) - const meta = { - title: post ? `${post?.title} | ${siteConfig('TITLE')}` : `${siteConfig('TITLE')} | loading`, - description: post?.summary, - type: post?.type, - slug: post?.slug, - image: post?.pageCoverThumbnail || (siteInfo?.pageCover || BLOG.HOME_BANNER_IMAGE), - category: post?.category?.[0], - tags: post?.tags - } - props = { ...props, lock, meta, setLock, validPassword } + props = { ...props, lock, setLock, validPassword } // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) return diff --git a/pages/_app.js b/pages/_app.js index 82b4ca72..6bf73a76 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -18,6 +18,7 @@ import useAdjustStyle from '@/hooks/useAdjustStyle' // 各种扩展插件 这个要阻塞引入 import ExternalPlugins from '@/components/ExternalPlugins' import { THEME } from '@/blog.config' +import GlobalHead from '@/components/GlobalHead' const MyApp = ({ Component, pageProps }) => { // 一些可能出现 bug 的样式,可以统一放入该钩子进行调整 @@ -28,6 +29,7 @@ const MyApp = ({ Component, pageProps }) => { return getQueryParam(route.asPath, 'theme') || THEME }, [route]) + // 整体布局 const GLayout = useCallback( props => { // 根据页面路径加载不同Layout文件 @@ -40,6 +42,7 @@ const MyApp = ({ Component, pageProps }) => { return ( + diff --git a/pages/archive/index.js b/pages/archive/index.js index a0a57f28..bbcc718c 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -1,6 +1,5 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import { useEffect } from 'react' -import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -9,9 +8,6 @@ import { formatDateFmt } from '@/lib/formatDate' import { siteConfig } from '@/lib/config' const ArchiveIndex = props => { - const { siteInfo } = props - const { locale } = useGlobal() - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) @@ -29,16 +25,6 @@ const ArchiveIndex = props => { } }, []) - const meta = { - title: `${locale.NAV.ARCHIVE} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'archive', - type: 'website' - } - - props = { ...props, meta } - return } diff --git a/pages/category/[category]/index.js b/pages/category/[category]/index.js index a623cc6b..4056e9a1 100644 --- a/pages/category/[category]/index.js +++ b/pages/category/[category]/index.js @@ -1,6 +1,5 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import React from 'react' -import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -12,24 +11,9 @@ import { siteConfig } from '@/lib/config' * @returns */ export default function Category(props) { - const { siteInfo } = props - const { locale } = useGlobal() - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ - siteConfig('TITLE') || '' - }`, - description: siteConfig('DESCRIPTION'), - slug: 'category/' + props.category, - image: siteInfo?.pageCover, - type: 'website' - } - - props = { ...props, meta } - return } diff --git a/pages/category/[category]/page/[page].js b/pages/category/[category]/page/[page].js index ae5124b1..85ee8e69 100644 --- a/pages/category/[category]/page/[page].js +++ b/pages/category/[category]/page/[page].js @@ -1,6 +1,5 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import React from 'react' -import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -13,23 +12,9 @@ import { siteConfig } from '@/lib/config' */ export default function Category(props) { - const { siteInfo } = props - const { locale } = useGlobal() // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ - siteConfig('TITLE') || '' - }`, - description: siteConfig('DESCRIPTION'), - slug: 'category/' + props.category, - image: siteInfo?.pageCover, - type: 'website' - } - - props = { ...props, meta } - return } diff --git a/pages/category/index.js b/pages/category/index.js index 85121910..bd32e187 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -1,6 +1,5 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import React from 'react' -import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -12,21 +11,9 @@ import { siteConfig } from '@/lib/config' * @returns */ export default function Category(props) { - const { locale } = useGlobal() - const { siteInfo } = props - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${locale.COMMON.CATEGORY} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'category', - type: 'website' - } - props = { ...props, meta } - return } diff --git a/pages/index.js b/pages/index.js index 18f7ec47..83f13da0 100644 --- a/pages/index.js +++ b/pages/index.js @@ -15,15 +15,7 @@ import { useRouter } from 'next/router' const Index = props => { // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - - const meta = { - title: `${siteConfig('TITLE')} | ${siteConfig('DESCRIPTION')}`, - description: siteConfig('DESCRIPTION'), - image: siteConfig('HOME_BANNER_IMAGE'), - slug: '', - type: 'website' - } - return + return } /** diff --git a/pages/page/[page].js b/pages/page/[page].js index c34aef1d..57e61068 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -11,21 +11,9 @@ import { siteConfig } from '@/lib/config' * @returns */ const Page = props => { - const { siteInfo } = props - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${props?.page} | Page | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'page/' + props.page, - type: 'website' - } - - props = { ...props, meta } - return } diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index 89bec089..22a33eda 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -1,5 +1,4 @@ import { getGlobalData } from '@/lib/notion/getNotionData' -import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' import BLOG from '@/blog.config' import { useRouter } from 'next/router' @@ -7,22 +6,9 @@ import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' const Index = props => { - const { keyword, siteInfo } = props - const { locale } = useGlobal() - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, - description: siteConfig('TITLE'), - image: siteInfo?.pageCover, - slug: 'search/' + (keyword || ''), - type: 'website' - } - - props = { ...props, meta } - return } diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 9de43cc1..6fcd3be8 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -1,5 +1,4 @@ import { getGlobalData } from '@/lib/notion/getNotionData' -import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' import BLOG from '@/blog.config' import { useRouter } from 'next/router' @@ -7,21 +6,10 @@ import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' const Index = props => { - const { keyword, siteInfo } = props - const { locale } = useGlobal() - + const { keyword } = props // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - - const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, - description: siteConfig('TITLE'), - image: siteInfo?.pageCover, - slug: 'search/' + (keyword || ''), - type: 'website' - } - - props = { ...props, meta, currentSearch: keyword } + props = { ...props, currentSearch: keyword } return } diff --git a/pages/search/index.js b/pages/search/index.js index fa45d2d5..43695ed5 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -1,5 +1,4 @@ import { getGlobalData } from '@/lib/notion/getNotionData' -import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import BLOG from '@/blog.config' import { getLayoutByTheme } from '@/themes/theme' @@ -11,14 +10,13 @@ import { siteConfig } from '@/lib/config' * @returns */ const Search = props => { - const { posts, siteInfo } = props - const { locale } = useGlobal() + const { posts } = props // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) const router = useRouter() - const keyword = getSearchKey(router) + const keyword = router?.query?.s let filteredPosts // 静态过滤 @@ -34,15 +32,7 @@ const Search = props => { filteredPosts = [] } - const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'search', - type: 'website' - } - - props = { ...props, meta, posts: filteredPosts } + props = { ...props, posts: filteredPosts } return } @@ -63,11 +53,4 @@ export async function getStaticProps() { } } -function getSearchKey(router) { - if (router.query && router.query.s) { - return router.query.s - } - return null -} - export default Search diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index 1d6c94d2..f1da323e 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -1,4 +1,3 @@ -import { useGlobal } from '@/lib/global' import { getGlobalData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useRouter } from 'next/router' @@ -11,21 +10,9 @@ import { siteConfig } from '@/lib/config' * @returns */ const Tag = props => { - const { locale } = useGlobal() - const { tag, siteInfo } = props - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - const meta = { - title: `${tag} | ${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'tag/' + tag, - type: 'website' - } - props = { ...props, meta } - return } diff --git a/pages/tag/[tag]/page/[page].js b/pages/tag/[tag]/page/[page].js index ab28fdbc..ce2951ab 100644 --- a/pages/tag/[tag]/page/[page].js +++ b/pages/tag/[tag]/page/[page].js @@ -1,4 +1,3 @@ -import { useGlobal } from '@/lib/global' import { getGlobalData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useRouter } from 'next/router' @@ -6,21 +5,8 @@ import { getLayoutByTheme } from '@/themes/theme' import { siteConfig } from '@/lib/config' const Tag = props => { - const { locale } = useGlobal() - const { tag, siteInfo } = props - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - - const meta = { - title: `${tag} | ${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'tag/' + tag, - type: 'website' - } - props = { ...props, meta } - return } diff --git a/pages/tag/index.js b/pages/tag/index.js index bb618414..5866b978 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -1,5 +1,4 @@ import { getGlobalData } from '@/lib/notion/getNotionData' -import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -11,21 +10,8 @@ import { siteConfig } from '@/lib/config' * @returns */ const TagIndex = props => { - const { locale } = useGlobal() - const { siteInfo } = props - // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme({ theme: siteConfig('THEME'), router: useRouter() }) - - const meta = { - title: `${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, - description: siteConfig('DESCRIPTION'), - image: siteInfo?.pageCover, - slug: 'tag', - type: 'website' - } - props = { ...props, meta } - return } diff --git a/themes/example/index.js b/themes/example/index.js index a3aa7729..ed1c5bda 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -25,7 +25,6 @@ import TagItem from './components/TagItem' import { useRouter } from 'next/router' import { Transition } from '@headlessui/react' import { Style } from './style' -import CommonHead from '@/components/CommonHead' import { siteConfig } from '@/lib/config' /** @@ -36,7 +35,7 @@ import { siteConfig } from '@/lib/config' * @constructor */ const LayoutBase = props => { - const { children, meta } = props + const { children } = props const { onLoading, fullWidth } = useGlobal() const router = useRouter() const { category, tag } = props @@ -65,9 +64,6 @@ const LayoutBase = props => { return (
- {/* SEO信息 */} - -