mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-24 23:16:52 +00:00
@@ -2,7 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
|||||||
import { LayoutSearch } from '@/themes'
|
import { LayoutSearch } from '@/themes'
|
||||||
import BLOG from '@/blog.config'
|
import BLOG from '@/blog.config'
|
||||||
import { useGlobal } from '@/lib/global'
|
import { useGlobal } from '@/lib/global'
|
||||||
import { getPostBlocks } from '@/lib/notion/getPostBlocks'
|
import { getDataFromCache } from '@/lib/cache/cache_manager'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将对象的指定字段拼接到字符串
|
* 将对象的指定字段拼接到字符串
|
||||||
@@ -59,14 +59,15 @@ export async function getServerSideProps ({ params: { keyword } }) {
|
|||||||
|
|
||||||
const filterPosts = []
|
const filterPosts = []
|
||||||
for (const post of allPosts) {
|
for (const post of allPosts) {
|
||||||
// const cacheKey = 'page_block_' + post.id
|
const cacheKey = 'page_block_' + post.id
|
||||||
const page = await getPostBlocks(post.id, 'search')
|
// const page = await getPostBlocks(post.id, 'search')
|
||||||
|
const page = await getDataFromCache(cacheKey)
|
||||||
const tagContent = post.tags ? post.tags.join(' ') : ''
|
const tagContent = post.tags ? post.tags.join(' ') : ''
|
||||||
const categoryContent = post.category ? post.category.join(' ') : ''
|
const categoryContent = post.category ? post.category.join(' ') : ''
|
||||||
const articleInfo = post.title + post.summary + tagContent + categoryContent
|
const articleInfo = post.title + post.summary + tagContent + categoryContent
|
||||||
let hit = articleInfo.indexOf(keyword) > -1
|
let hit = articleInfo.indexOf(keyword) > -1
|
||||||
let indexContent = [post.summary]
|
let indexContent = [post.summary]
|
||||||
if (page !== null) {
|
if (page && page.block) {
|
||||||
const contentIds = Object.keys(page.block)
|
const contentIds = Object.keys(page.block)
|
||||||
contentIds.forEach(id => {
|
contentIds.forEach(id => {
|
||||||
const properties = page?.block[id]?.value?.properties
|
const properties = page?.block[id]?.value?.properties
|
||||||
|
|||||||
Reference in New Issue
Block a user