mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 07:26:47 +00:00
build: 修复预编译
This commit is contained in:
@@ -4,7 +4,7 @@ import Live2D from '@/components/Live2D'
|
||||
import TocDrawer from '@/components/TocDrawer'
|
||||
import TocDrawerButton from '@/components/TocDrawerButton'
|
||||
import BaseLayout from '@/layouts/BaseLayout'
|
||||
import { getAllPosts, getPostBlocks } from '@/lib/notion'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import Custom404 from '@/pages/404'
|
||||
import { getPageTableOfContents } from 'notion-utils'
|
||||
@@ -69,12 +69,17 @@ const Slug = ({
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
let posts = []
|
||||
if (BLOG.isProd) {
|
||||
posts = await getAllPosts({ from: 'slug - paths', includePage: false })
|
||||
if (!BLOG.isProd) {
|
||||
return {
|
||||
paths: [],
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
const from = '[slug-paths'
|
||||
const { allPosts } = await getGlobalNotionData({ from, includePage: false })
|
||||
return {
|
||||
paths: posts.map(row => ({ params: { slug: row.slug } })),
|
||||
paths: allPosts.map(row => ({ params: { slug: row.slug } })),
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import StickyBar from '@/components/StickyBar'
|
||||
import TagList from '@/components/TagList'
|
||||
import BaseLayout from '@/layouts/BaseLayout'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { getAllPosts } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
|
||||
export default function Tag ({ tags, posts, tag, categories, postCount, latestPosts }) {
|
||||
@@ -56,27 +55,21 @@ export async function getStaticProps ({ params }) {
|
||||
* @param {*}} allPosts
|
||||
* @returns
|
||||
*/
|
||||
function getTagNames (allPosts) {
|
||||
const tags = allPosts.map(p => p.tags).flat()
|
||||
|
||||
const tagObj = {}
|
||||
function getTagNames (tags) {
|
||||
const tagNames = []
|
||||
tags.forEach(tag => {
|
||||
if (tag in tagObj) {
|
||||
tagObj[tag]++
|
||||
} else {
|
||||
tagObj[tag] = 1
|
||||
}
|
||||
tagNames.push(tag.name)
|
||||
})
|
||||
return tagObj
|
||||
return tagNames
|
||||
}
|
||||
|
||||
export async function getStaticPaths () {
|
||||
const from = 'tag-static-path'
|
||||
const posts = await getAllPosts({ from })
|
||||
const tagNames = getTagNames(posts)
|
||||
const { tags } = await getGlobalNotionData({ from, tagsCount: 0 })
|
||||
const tagNames = getTagNames(tags)
|
||||
|
||||
return {
|
||||
paths: Object.keys(tagNames).map(tag => ({ params: { tag } })),
|
||||
paths: Object.keys(tagNames).map(index => ({ params: { tag: tagNames[index] } })),
|
||||
fallback: true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user