站点信息读取Notion数据

This commit is contained in:
tangly1024
2022-03-30 15:34:25 +08:00
parent 914e9a108f
commit 53c004843e
61 changed files with 322 additions and 463 deletions

View File

@@ -1,11 +1,9 @@
import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import LayoutBase from './LayoutBase'
export const LayoutArchive = props => {
const { posts } = props
const { locale } = useGlobal()
const postsSortByDate = Object.create(posts)
postsSortByDate.sort((a, b) => {
@@ -14,12 +12,6 @@ export const LayoutArchive = props => {
return dateB - dateA
})
const meta = {
title: `${locale.NAV.ARCHIVE} | ${BLOG.TITLE}`,
description: BLOG.DESCRIPTION,
type: 'website'
}
const archivePosts = {}
postsSortByDate.forEach(post => {
@@ -31,7 +23,7 @@ export const LayoutArchive = props => {
}
})
return (
<LayoutBase {...props} meta={meta}>
<LayoutBase {...props}>
<div className="mb-10 pb-20 md:p-12 p-3 min-h-full">
{Object.keys(archivePosts).map(archiveTitle => (
<div key={archiveTitle}>

View File

@@ -11,7 +11,7 @@ import { useGlobal } from '@/lib/global'
* @constructor
*/
const LayoutBase = props => {
const { children, meta, customNav } = props
const { children, meta, customNav, siteInfo } = props
const { locale } = useGlobal()
const d = new Date()
const currentYear = d.getFullYear()
@@ -35,10 +35,10 @@ const LayoutBase = props => {
<div className="w-full flex justify-center my-2">
<div className=" max-w-6xl justify-between w-full flex">
<section>
<Link title={BLOG.TITLE} href={'/'}>
<Link title={siteInfo.title} href={'/'}>
<a className={'cursor-pointer flex items-center hover:underline'}>
<i className={'fas fa-home mr-1'} />
<div className="text-center">{BLOG.TITLE} </div>
<div className="text-center">{siteInfo.title} </div>
</a>
</Link>
</section>
@@ -126,7 +126,7 @@ const LayoutBase = props => {
<span className="px-1 busuanzi_value_site_uv"> </span>{' '}
</span>
<br />
<h1>{meta?.title || BLOG.TITLE}</h1>
<h1>{meta?.title || siteInfo.title}</h1>
</footer>
</div>
)

View File

@@ -1,4 +1,3 @@
import BLOG from '@/blog.config'
import { getPageTableOfContents } from 'notion-utils'
import 'prismjs'
import 'prismjs/components/prism-bash'
@@ -24,13 +23,6 @@ const mapPageUrl = id => {
export const LayoutSlug = props => {
const { post, lock, validPassword } = props
const meta = {
title: `${post.title} | ${BLOG.TITLE}`,
description: post.summary,
type: 'article',
tags: post.tags
}
if (!lock && post?.blockMap?.block) {
post.content = Object.keys(post.blockMap.block)
post.toc = getPageTableOfContents(post, post.blockMap)
@@ -55,7 +47,7 @@ export const LayoutSlug = props => {
}
})
return (
<LayoutBase {...props} meta={meta}>
<LayoutBase {...props}>
<div>
<h2>{post?.title}</h2>