mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
bugfix:
SEO
This commit is contained in:
@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
const Footer = ({ fullWidth = true }) => {
|
||||
const Footer = ({ title }) => {
|
||||
const d = new Date()
|
||||
const y = d.getFullYear()
|
||||
return (
|
||||
@@ -13,13 +13,15 @@ const Footer = ({ fullWidth = true }) => {
|
||||
<FontAwesomeIcon icon={faCopyright} /> {` ${y}`} <span> <a href='https://tangly1024.com/article/about' className='underline font-bold text-gray-100'>tangly1024.com</a>. Powered by <a href='https://notion.so' className='underline font-bold text-gray-100'>Notion</a> & <a href='https://github.com/tangly1024/NotionNext' className='underline font-bold text-gray-100'>NotionNext</a>.</span>
|
||||
<br />
|
||||
<FontAwesomeIcon icon={faShieldAlt} /> <a href='https://beian.miit.gov.cn/' className='ml-1 font-bold'>闽ICP备20010331号</a>
|
||||
<span > <Link href='/article/privacy-policy' ><a className='ml-1 font-bold underline'>隐私政策</a></Link></span>
|
||||
<span > <Link href='/article/privacy-policy' ><a className='ml-1 mr-1 font-bold underline'>隐私政策</a></Link></span>
|
||||
|
||||
<span id='busuanzi_container_site_pv' className='hidden'>
|
||||
<FontAwesomeIcon icon={faEye}/><span id='busuanzi_value_site_pv' className='px-1'> </span>pv
|
||||
</span>
|
||||
<span id='busuanzi_container_site_uv' className='pl-2 hidden'>
|
||||
<FontAwesomeIcon icon={faUser}/> <span id='busuanzi_value_site_uv' className='px-1'> </span>uv </span>
|
||||
<br/>
|
||||
<h1>{title}</h1>
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -23,9 +23,10 @@ import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/fr
|
||||
* @returns {JSX.Element}
|
||||
* @constructor
|
||||
*/
|
||||
const SideBar = ({ tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => {
|
||||
const SideBar = ({ title, tags, currentTag, post, posts, categories, currentCategory, currentSearch }) => {
|
||||
const { locale } = useGlobal()
|
||||
return <aside id='sidebar' className='pt-5 bg-white dark:bg-gray-900 w-72 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'>
|
||||
|
||||
<section className='hidden lg:block'>
|
||||
<InfoCard />
|
||||
<hr className='dark:border-gray-700 mt-6 py-1' />
|
||||
|
||||
@@ -7,7 +7,7 @@ import Link from 'next/link'
|
||||
import Image from 'next/image'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
|
||||
const TopNav = ({ tags, currentTag, post, posts, currentSearch, categories, currentCategory }) => {
|
||||
const TopNav = ({ tags, currentTag, post, posts, categories, currentCategory }) => {
|
||||
const drawer = useRef()
|
||||
const { locale } = useGlobal()
|
||||
|
||||
@@ -16,10 +16,10 @@ const TopNav = ({ tags, currentTag, post, posts, currentSearch, categories, curr
|
||||
<SideBarDrawer post={post} currentTag={currentTag} cRef={drawer} tags={tags} posts={posts} categories={categories} currentCategory={currentCategory}/>
|
||||
|
||||
{/* 导航栏 */}
|
||||
<div id='sticky-nav' className='fixed w-full top-0 z-20 transform duration-500 glassmorphism'>
|
||||
<div className='w-full flex justify-between items-center p-4 shadow-lg'>
|
||||
{/* 左侧LOGO */}
|
||||
<div className='flex'>
|
||||
<div id='sticky-nav' className='flex fixed w-full top-0 z-20 transform duration-500 glassmorphism'>
|
||||
<div className='w-full flex justify-between items-center p-4 shadow-lg '>
|
||||
{/* 左侧LOGO 标题 */}
|
||||
<div className='flex flex-none flex-grow-0'>
|
||||
<div className='relative w-10' ><Image
|
||||
alt={BLOG.title}
|
||||
layout='fill'
|
||||
@@ -29,13 +29,13 @@ const TopNav = ({ tags, currentTag, post, posts, currentSearch, categories, curr
|
||||
/></div>
|
||||
<Link href='/' passHref>
|
||||
<a>
|
||||
<h1 className='cursor-pointer ml-2 text-xl hover:scale-105 duration-200 transform font-serif dark:text-gray-200 whitespace-nowrap overflow-x-hidden'>{BLOG.title }</h1>
|
||||
<h1 className='cursor-pointer ml-2 w-full hover:scale-105 duration-200 transform font-serif dark:text-gray-200 whitespace-nowrap overflow-x-hidden'>{ BLOG.title }</h1>
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* 右侧功能 */}
|
||||
<div className='mr-1 flex justify-end items-center text-sm flex-nowrap space-x-4 font-serif dark:text-gray-200'>
|
||||
<div className='mr-1 flex flex-nowrap flex-grow justify-end items-center text-sm space-x-4 font-serif dark:text-gray-200'>
|
||||
<Link href='/'>
|
||||
<a>{locale.NAV.INDEX}</a>
|
||||
</Link>
|
||||
|
||||
@@ -74,7 +74,7 @@ const BaseLayout = ({
|
||||
{/* Middle Wrapper */}
|
||||
<div className='flex dark:bg-black'>
|
||||
<div className='hidden shadow lg:block z-10'>
|
||||
<SideBar post={post} posts={totalPosts} tags={tags} currentSearch={currentSearch} currentTag={currentTag} categories={categories} currentCategory={currentCategory} />
|
||||
<SideBar title={meta.title} post={post} posts={totalPosts} tags={tags} currentSearch={currentSearch} currentTag={currentTag} categories={categories} currentCategory={currentCategory} />
|
||||
</div>
|
||||
<div className='flex flex-grow min-h-screen' ref={targetRef}>
|
||||
{onLoading
|
||||
@@ -86,7 +86,7 @@ const BaseLayout = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
<Footer title={meta.title}/>
|
||||
|
||||
<JumpToTopButton targetRef={targetRef} showPercent={true} />
|
||||
<FloatDarkModeButton/>
|
||||
|
||||
@@ -18,7 +18,7 @@ const Slug = ({ post, blockMap, tags, prev, next, allPosts, recommendPosts, cate
|
||||
return <Custom404 />
|
||||
}
|
||||
const meta = {
|
||||
title: `${post.title}`,
|
||||
title: `${BLOG.title} | ${post.title}`,
|
||||
description: post.summary,
|
||||
type: 'article',
|
||||
tags: post.tags
|
||||
@@ -30,7 +30,10 @@ const Slug = ({ post, blockMap, tags, prev, next, allPosts, recommendPosts, cate
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
const posts = await getAllPosts({ from: 'slug - paths', includePage: true })
|
||||
let posts = []
|
||||
if (BLOG.isProd) {
|
||||
posts = await getAllPosts({ from: 'slug - paths', includePage: true })
|
||||
}
|
||||
return {
|
||||
paths: posts.map(row => `${BLOG.path}/article/${row.slug}`),
|
||||
fallback: true
|
||||
|
||||
@@ -49,10 +49,8 @@ export async function getStaticProps ({ params }) {
|
||||
export async function getStaticPaths () {
|
||||
let posts = []
|
||||
let categories = []
|
||||
if (BLOG.isProd) {
|
||||
posts = await getAllPosts({ from: 'category-path' })
|
||||
categories = await getAllCategories(posts)
|
||||
}
|
||||
posts = await getAllPosts({ from: 'category-path' })
|
||||
categories = await getAllCategories(posts)
|
||||
return {
|
||||
paths: Object.keys(categories).map(category => ({ params: { category } })),
|
||||
fallback: true
|
||||
|
||||
@@ -6,24 +6,25 @@ import BlogPostListScroll from '@/components/BlogPostListScroll'
|
||||
import TagList from '@/components/TagList'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
|
||||
export default function Tag ({ tags, allPosts, filteredPosts, currentTag, categories }) {
|
||||
export default function Tag ({ tags, allPosts, filteredPosts, tag, categories }) {
|
||||
const meta = {
|
||||
title: `${BLOG.title} | #${currentTag}`,
|
||||
title: `${BLOG.title} | #${tag}`,
|
||||
description: BLOG.description,
|
||||
type: 'website'
|
||||
}
|
||||
return <BaseLayout meta={meta} tags={tags} currentTag={currentTag} categories={categories} totalPosts={allPosts}>
|
||||
<div className=' pt-16'>
|
||||
|
||||
return <BaseLayout meta={meta} tags={tags} currentTag={tag} categories={categories} totalPosts={allPosts}>
|
||||
<div className='pt-16'>
|
||||
<StickyBar>
|
||||
<TagList tags={tags} currentTag={currentTag}/>
|
||||
<TagList tags={tags} currentTag={tag}/>
|
||||
</StickyBar>
|
||||
<BlogPostListScroll posts={filteredPosts} tags={tags} currentTag={currentTag}/>
|
||||
<BlogPostListScroll posts={filteredPosts} tags={tags} currentTag={tag}/>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
}
|
||||
|
||||
export async function getStaticProps ({ params }) {
|
||||
const currentTag = params.tag
|
||||
const tag = params.tag
|
||||
const from = 'tag-props'
|
||||
const notionPageData = await getNotionPageData({ from })
|
||||
const allPosts = await getAllPosts({ notionPageData, from })
|
||||
@@ -31,14 +32,14 @@ export async function getStaticProps ({ params }) {
|
||||
const tagOptions = notionPageData.tagOptions
|
||||
const tags = await getAllTags({ allPosts, tagOptions, sliceCount: 0 })
|
||||
const filteredPosts = allPosts.filter(
|
||||
post => post && post.tags && post.tags.includes(currentTag)
|
||||
post => post && post.tags && post.tags.includes(tag)
|
||||
)
|
||||
return {
|
||||
props: {
|
||||
tags,
|
||||
allPosts,
|
||||
filteredPosts,
|
||||
currentTag,
|
||||
tag,
|
||||
categories
|
||||
},
|
||||
revalidate: 1
|
||||
@@ -46,14 +47,17 @@ export async function getStaticProps ({ params }) {
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
let posts = []
|
||||
let tags = []
|
||||
if (BLOG.isProd) {
|
||||
posts = await getAllPosts({ from: 'tag-props' })
|
||||
tags = await getAllTags(posts)
|
||||
}
|
||||
// const tags = []
|
||||
const from = 'tag-static-path'
|
||||
const notionPageData = await getNotionPageData({ from })
|
||||
const posts = await getAllPosts({ notionPageData, from })
|
||||
const categories = await getAllCategories(posts)
|
||||
|
||||
// const tagOptions = notionPageData.tagOptions
|
||||
// tags = await getAllTags({ posts, tagOptions, sliceCount: 0 })
|
||||
return {
|
||||
paths: Object.keys(tags).map(tag => ({ params: { tag } })),
|
||||
paths: Object.keys(categories).map(category => ({ params: { category } })),
|
||||
// paths: tags.map(t => ({ params: { tag: t.name } })),
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user