diff --git a/.env.local b/.env.local index 3eba4322..7ed26a3c 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=4.0.6 \ No newline at end of file +NEXT_PUBLIC_VERSION=4.0.7 \ No newline at end of file diff --git a/blog.config.js b/blog.config.js index f19effce..fab696b8 100644 --- a/blog.config.js +++ b/blog.config.js @@ -376,7 +376,7 @@ const BLOG = { // 开发相关 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, // 是否显示调试按钮 - ENABLE_CACHE: process.env.ENABLE_CACHE || false, // 开启缓存会将Notion数据缓存在内存中,通常在开发调试中使用,正式部署开启此功能意义不大。 + ENABLE_CACHE: process.env.ENABLE_CACHE || process.env.npm_lifecycle_event === 'build', // 缓存在开发调试和打包过程中选择性开启,正式部署开启此功能意义不大。 isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号 } diff --git a/components/AlgoliaSearchModal.js b/components/AlgoliaSearchModal.js index 7af1fd6a..71f363c7 100644 --- a/components/AlgoliaSearchModal.js +++ b/components/AlgoliaSearchModal.js @@ -132,7 +132,7 @@ export default function AlgoliaSearchModal({ cRef }) {
{totalHit > 0 &&
共搜索到 {totalHit} 条结果,用时 {useTime} 毫秒
}
-
Algolia 提供搜索服务
+
Algolia 提供搜索服务
{/* 遮罩 */} diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index d452eb5f..24b1fb8e 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -174,8 +174,8 @@ function getSiteInfo({ collection, block }) { } /** - * 获取导航pages - * 转为gitbook这类文档主题设计,精减的标题和内容 + * 获取导航用的精减文章列表 + * gitbook主题用到,只保留文章的标题分类标签分类信息,精减掉摘要密码日期等数据 * 导航页面的条件,必须是Posts * @param {*} param0 */ @@ -183,22 +183,8 @@ export function getNavPages({ allPages }) { const allNavPages = allPages.filter(post => { return post && post?.slug && (!post?.slug?.startsWith('http')) && post?.type === 'Post' && post?.status === 'Published' }) - const result = allNavPages.map(item => ({ id: item.id, title: item.title || '', category: item.category || null, tags: item.tags || null, summary: item.summary || null, slug: item.slug })) - const groupedArray = result.reduce((groups, item) => { - const categoryName = item?.category ? item?.category : '' // 将category转换为字符串 - const lastGroup = groups[groups.length - 1] // 获取最后一个分组 - - if (!lastGroup || lastGroup?.category !== categoryName) { // 如果当前元素的category与上一个元素不同,则创建新分组 - groups.push({ category: categoryName, items: [] }) - } - - groups[groups.length - 1].items.push(item) // 将元素加入对应的分组 - - return groups - }, []) - - return groupedArray + return allNavPages.map(item => ({ id: item.id, title: item.title || '', pageCoverThumbnail: item.pageCoverThumbnail || '', category: item.category || null, tags: item.tags || null, summary: item.summary || null, slug: item.slug })) } /** diff --git a/package.json b/package.json index b9f1bb5c..21def24a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "4.0.6", + "version": "4.0.7", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { diff --git a/pages/_app.js b/pages/_app.js index 57c4047a..ed0c8f76 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -17,8 +17,6 @@ import dynamic from 'next/dynamic' // 自定义样式css和js引入 import ExternalScript from '@/components/ExternalScript' -import CommonHead from '@/components/CommonHead' - // 各种扩展插件 动画等 const ExternalPlugins = dynamic(() => import('@/components/ExternalPlugins')) @@ -26,11 +24,9 @@ const MyApp = ({ Component, pageProps }) => { useEffect(() => { AOS.init() }, []) - const { meta } = pageProps return ( - diff --git a/pages/index.js b/pages/index.js index 86d9de24..fbbe0eff 100644 --- a/pages/index.js +++ b/pages/index.js @@ -3,7 +3,6 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalData } from '@/lib/notion/getNotionData' import { generateRss } from '@/lib/rss' import { generateRobotsTxt } from '@/lib/robots.txt' - import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' @@ -12,7 +11,6 @@ import { getLayoutByTheme } from '@/themes/theme' * @param {*} props * @returns */ - const Index = props => { // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme(useRouter()) diff --git a/themes/example/index.js b/themes/example/index.js index 8dffec78..0772f7fd 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -26,6 +26,7 @@ import TagItem from './components/TagItem' import { useRouter } from 'next/router' import { Transition } from '@headlessui/react' import { Style } from './style' +import CommonHead from '@/components/CommonHead' /** * 基础布局框架 @@ -35,7 +36,7 @@ import { Style } from './style' * @constructor */ const LayoutBase = props => { - const { children, slotTop } = props + const { children, slotTop, meta } = props const { onLoading } = useGlobal() // 增加一个状态以触发 Transition 组件的动画 @@ -48,6 +49,10 @@ const LayoutBase = props => { return (
+ + {/* SEO信息 */} + +