mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
@@ -109,11 +109,13 @@ async function getCustomNav ({ notionPageData }) {
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function getTagOptions (schema) {
|
||||
if (!schema) return {}
|
||||
const tagSchema = Object.values(schema).find(e => e.name === 'tags')
|
||||
return tagSchema?.options || {}
|
||||
}
|
||||
|
||||
function getCategoryOptions (schema) {
|
||||
if (!schema) return {}
|
||||
const categorySchema = Object.values(schema).find(e => e.name === 'category')
|
||||
return categorySchema?.options || {}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ function appendText (sourceTextArray, targetObj, key) {
|
||||
* @returns
|
||||
*/
|
||||
function getTextContent (textArray) {
|
||||
if (typeof textArray === 'object') {
|
||||
if (typeof textArray === 'object' && isIterable(textArray)) {
|
||||
let result = ''
|
||||
for (const textObj of textArray) {
|
||||
result = result + getTextContent(textObj)
|
||||
@@ -40,6 +40,13 @@ function getTextContent (textArray) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象是否可以遍历
|
||||
* @param {*} obj
|
||||
* @returns
|
||||
*/
|
||||
const isIterable = obj => obj != null && typeof obj[Symbol.iterator] === 'function'
|
||||
|
||||
export async function getServerSideProps ({ params: { keyword } }) {
|
||||
const {
|
||||
allPosts,
|
||||
@@ -67,8 +74,7 @@ export async function getServerSideProps ({ params: { keyword } }) {
|
||||
indexContent = appendText(indexContent, properties, 'caption')
|
||||
})
|
||||
}
|
||||
console.log('搜索是否命中缓存', page !== null, indexContent)
|
||||
|
||||
// console.log('搜索是否命中缓存', page !== null, indexContent)
|
||||
post.results = []
|
||||
let hitCount = 0
|
||||
const re = new RegExp(`${keyword}`, 'gim')
|
||||
|
||||
Reference in New Issue
Block a user