mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-09 07:26:47 +00:00
theme-simple & menun
This commit is contained in:
@@ -85,18 +85,39 @@ function getCustomNav({ allPages }) {
|
||||
const customNav = []
|
||||
if (allPages && allPages.length > 0) {
|
||||
allPages.forEach(p => {
|
||||
if (p?.status === 'Published' && p?.type === 'Page') {
|
||||
if (p?.slug?.indexOf('http') === 0) {
|
||||
customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, show: true })
|
||||
} else {
|
||||
customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, show: true })
|
||||
}
|
||||
if (p?.slug?.indexOf('http') === 0) {
|
||||
customNav.push({ icon: p.icon || null, name: p.title, to: p.slug, show: true })
|
||||
} else {
|
||||
customNav.push({ icon: p.icon || null, name: p.title, to: '/' + p.slug, show: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
return customNav
|
||||
}
|
||||
|
||||
function getCustomMenu({ collectionData }) {
|
||||
const menuPages = collectionData.filter(post => (post.type === BLOG.NOTION_PROPERTY_NAME.type_menu || post.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) && post.status === 'Published')
|
||||
const menus = []
|
||||
if (menuPages && menuPages.length > 0) {
|
||||
menuPages.forEach(e => {
|
||||
e.show = true
|
||||
if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) {
|
||||
menus.push(e)
|
||||
} else if (e.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) {
|
||||
const parentMenu = menus[menus.length - 1]
|
||||
if (parentMenu) {
|
||||
if (parentMenu.subMenus) {
|
||||
parentMenu.subMenus.push(e)
|
||||
} else {
|
||||
parentMenu.subMenus = [e]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return menus
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签选项
|
||||
* @param schema
|
||||
@@ -219,6 +240,8 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
|
||||
const tagOptions = getAllTags({ allPages, tagOptions: getTagOptions(schema) })
|
||||
const siteInfo = getBlogInfo({ collection, block })
|
||||
const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') })
|
||||
// 新的菜单
|
||||
const customMenu = getCustomMenu({ collectionData })
|
||||
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 })
|
||||
|
||||
return {
|
||||
@@ -236,6 +259,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
|
||||
categoryOptions,
|
||||
rawMetadata,
|
||||
customNav,
|
||||
customMenu,
|
||||
postCount,
|
||||
pageIds,
|
||||
latestPosts
|
||||
|
||||
Reference in New Issue
Block a user