🕶 修复编译异常

This commit is contained in:
tangly1024
2021-09-29 14:20:34 +08:00
parent 3fe53e81b9
commit 791af3a1af
4 changed files with 55 additions and 34 deletions

45
components/CommonHead.js Normal file
View File

@@ -0,0 +1,45 @@
import BLOG from '@/blog.config'
import Head from 'next/head'
const CommonHead = ({ meta }) => {
const url = BLOG.path.length ? `${BLOG.link}/${BLOG.path}` : BLOG.link
return <Head>
<title>{meta.title}</title>
<meta content={BLOG.darkBackground} name='theme-color' />
<meta name='robots' content='follow, index' />
<meta charSet='UTF-8' />
{BLOG.seo.googleSiteVerification && (
<meta
name='google-site-verification'
content={BLOG.seo.googleSiteVerification}
/>
)}
{BLOG.seo.keywords && (
<meta name='keywords' content={BLOG.seo.keywords.join(', ')} />
)}
<meta name='description' content={meta.description} />
<meta property='og:locale' content={BLOG.lang} />
<meta property='og:title' content={meta.title} />
<meta property='og:description' content={meta.description} />
<meta
property='og:url'
content={meta.slug ? `${url}/${meta.slug}` : url}
/>
<meta property='og:type' content={meta.type} />
<meta name='twitter:card' content='summary_large_image' />
<meta name='twitter:description' content={meta.description} />
<meta name='twitter:title' content={meta.title} />
{meta.type === 'article' && (
<>
<meta
property='article:published_time'
content={meta.date || meta.createdTime}
/>
<meta property='article:author' content={BLOG.author} />
</>
)}
</Head>
}
export default CommonHead

View File

@@ -14,7 +14,7 @@ import BlogPostMini from '@/components/BlogPostMini'
import { useRouter } from 'next/router'
import ShareButton from '@/components/ShareButton'
import TopJumper from '@/components/TopJumper'
import { Head } from 'next/document'
import CommonHead from '@/components/CommonHead'
const mapPageUrl = id => {
return 'https://www.notion.so/' + id.replace(/-/g, '')
@@ -40,26 +40,7 @@ const ArticleLayout = ({
return (
<div className={`${BLOG.font} ${theme}`}>
<Head>
<title>{meta.title}</title>
<meta name='description' content={meta.description} />
<meta property='og:title' content={meta.title} />
<meta property='og:description' content={meta.description} />
<meta
property='og:url'
content={meta.slug ? `${url}/${meta.slug}` : url}
/>
<meta property='og:type' content={meta.type} />
{meta.type === 'article' && (
<>
<meta
property='article:published_time'
content={meta.date || meta.createdTime}
/>
<meta property='article:author' content={BLOG.author} />
</>
)}
</Head>
<CommonHead meta={meta} />
{/* live2d 看板娘 */}
<script async src='https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js' />

View File

@@ -7,8 +7,14 @@ import { useTheme } from '@/lib/theme'
import { useEffect, useState } from 'react'
import SideBar from '@/components/SideBar'
import throttle from 'lodash.throttle'
import CommonHead from '@/components/CommonHead'
const DefaultLayout = ({ tags, posts, page, currentTag, ...customMeta }) => {
const meta = {
title: BLOG.title,
type: 'website',
...customMeta
}
page = page ?? 1
let postsToShow = []
let filteredBlogPosts = posts ?? []
@@ -71,6 +77,7 @@ const DefaultLayout = ({ tags, posts, page, currentTag, ...customMeta }) => {
return (
<div id='wrapper' className={theme}>
<CommonHead meta={meta}/>
{/* <TopNav tags={tags} currentTag={currentTag} /> */}
{/* <Header navBarTitle={meta.title} fullWidth={true}/> */}

View File

@@ -12,21 +12,9 @@ class MyDocument extends Document {
return (
<Html lang={BLOG.lang}>
<Head>
<title>{BLOG.title}</title>
<link rel='icon' href='/favicon.ico' />
<link rel='icon' href='/favicon.svg' type='image/svg+xml' />
<meta property='og:locale' content={BLOG.lang} />
<meta content={BLOG.darkBackground} name='theme-color' />
<meta name='robots' content='follow, index' />
<meta charSet='UTF-8' />
{BLOG.seo.googleSiteVerification && (
<meta
name='google-site-verification'
content={BLOG.seo.googleSiteVerification}
/>
)}
{BLOG.seo.keywords && (
<meta name='keywords' content={BLOG.seo.keywords.join(', ')} />
)}
<ThirdPartyScript />
</Head>