mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-29 15:10:06 +00:00
example 主题 调整 tag\category 结构
This commit is contained in:
@@ -58,10 +58,10 @@ export async function getStaticProps({ params: { category } }) {
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const from = 'category-paths'
|
||||
const { categories } = await getGlobalNotionData({ from })
|
||||
const { categoryOptions } = await getGlobalNotionData({ from })
|
||||
return {
|
||||
paths: Object.keys(categories).map(category => ({
|
||||
params: { category: categories[category]?.name }
|
||||
paths: Object.keys(categoryOptions).map(category => ({
|
||||
params: { category: categoryOptions[category]?.name }
|
||||
})),
|
||||
fallback: true
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ export async function getStaticProps({ params: { category, page } }) {
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const from = 'category-paths'
|
||||
const { categories, allPages } = await getGlobalNotionData({ from })
|
||||
const { categoryOptions, allPages } = await getGlobalNotionData({ from })
|
||||
const paths = []
|
||||
|
||||
categories?.forEach(category => {
|
||||
categoryOptions?.forEach(category => {
|
||||
// 过滤状态类型
|
||||
const categoryPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published').filter(post => post && post.category && post.category.includes(category.name))
|
||||
// 处理文章页数
|
||||
|
||||
@@ -2,7 +2,6 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import { getAllCategories } from '@/lib/notion/getAllCategories'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
/**
|
||||
@@ -27,8 +26,6 @@ export default function Category(props) {
|
||||
|
||||
export async function getStaticProps() {
|
||||
const props = await getGlobalNotionData({ from: 'category-index-props' })
|
||||
props.categories = getAllCategories({ allPages: props.allPages, categoryOptions: props.categoryOptions, sliceCount: 0 })
|
||||
delete props.categoryOptions
|
||||
delete props.allPages
|
||||
return {
|
||||
props,
|
||||
|
||||
@@ -63,8 +63,8 @@ function getTagNames(tags) {
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const from = 'tag-static-path'
|
||||
const { tags } = await getGlobalNotionData({ from })
|
||||
const tagNames = getTagNames(tags)
|
||||
const { tagOptions } = await getGlobalNotionData({ from })
|
||||
const tagNames = getTagNames(tagOptions)
|
||||
|
||||
return {
|
||||
paths: Object.keys(tagNames).map(index => ({
|
||||
|
||||
@@ -44,9 +44,9 @@ export async function getStaticProps({ params: { tag, page } }) {
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const from = 'tag-page-static-path'
|
||||
const { tags, allPages } = await getGlobalNotionData({ from })
|
||||
const { tagOptions, allPages } = await getGlobalNotionData({ from })
|
||||
const paths = []
|
||||
tags?.forEach(tag => {
|
||||
tagOptions?.forEach(tag => {
|
||||
// 过滤状态类型
|
||||
const tagPosts = allPages.filter(page => page.type === 'Post' && page.status === 'Published').filter(post => post && post.tags && post.tags.includes(tag.name))
|
||||
// 处理文章页数
|
||||
|
||||
@@ -2,7 +2,6 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import React from 'react'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import { getAllTags } from '@/lib/notion'
|
||||
import BLOG from '@/blog.config'
|
||||
|
||||
/**
|
||||
@@ -28,8 +27,6 @@ const TagIndex = props => {
|
||||
export async function getStaticProps() {
|
||||
const from = 'tag-index-props'
|
||||
const props = await getGlobalNotionData({ from })
|
||||
props.tags = getAllTags({ allPages: props.allPages, sliceCount: 0, tagOptions: props.tagOptions })
|
||||
delete props.tagOptions
|
||||
delete props.allPages
|
||||
return {
|
||||
props,
|
||||
|
||||
Reference in New Issue
Block a user