Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复菜单自定义名的bug #2834

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/db/getSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,15 @@ function getCustomMenu({ collectionData, NOTION_CONFIG }) {
const menuPages = collectionData.filter(
post =>
post.status === 'Published' &&
(post?.type === BLOG.NOTION_PROPERTY_NAME.type_menu ||
post?.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu)
(post?.type === 'Menu' || post?.type === 'SubMenu')
)
const menus = []
if (menuPages && menuPages.length > 0) {
menuPages.forEach(e => {
e.show = true
if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) {
if (e.type === 'Menu') {
menus.push(e)
} else if (e.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) {
} else if (e.type === 'SubMenu') {
const parentMenu = menus[menus.length - 1]
if (parentMenu) {
if (parentMenu.subMenus) {
Expand Down
27 changes: 16 additions & 11 deletions lib/notion/getPageProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,25 @@ function convertToJSON(str) {
* 映射用户自定义表头
*/
function mapProperties(properties) {
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
properties.type = 'Post'
const typeMap = {
[BLOG.NOTION_PROPERTY_NAME.type_post]: 'Post',
[BLOG.NOTION_PROPERTY_NAME.type_page]: 'Page',
[BLOG.NOTION_PROPERTY_NAME.type_notice]: 'Notice',
[BLOG.NOTION_PROPERTY_NAME.type_menu]: 'Menu',
[BLOG.NOTION_PROPERTY_NAME.type_sub_menu]: 'SubMenu'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_page) {
properties.type = 'Page'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_notice) {
properties.type = 'Notice'

const statusMap = {
[BLOG.NOTION_PROPERTY_NAME.status_publish]: 'Published',
[BLOG.NOTION_PROPERTY_NAME.status_invisible]: 'Invisible'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_publish) {
properties.status = 'Published'

if (properties?.type && typeMap[properties.type]) {
properties.type = typeMap[properties.type]
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_invisible) {
properties.status = 'Invisible'

if (properties?.status && statusMap[properties.status]) {
properties.status = statusMap[properties.status]
}
}

Expand Down