slug 兼容性优化,支持用任意前缀访问文章不限于article

This commit is contained in:
tangly1024.com
2024-05-08 15:13:12 +08:00
parent f803b7ad06
commit de0908ea94
7 changed files with 209 additions and 151 deletions

View File

@@ -156,19 +156,11 @@ function getCustomNav({ allPages }) {
if (allPages && allPages.length > 0) {
allPages.forEach(p => {
p.to = p.slug
if (p?.slug?.indexOf('http') === 0) {
p.target = '_blank'
} else {
p.target = '_self'
if (p?.slug?.indexOf('/') !== 0) {
p.to = '/' + p.slug
}
}
customNav.push({
icon: p.icon || null,
name: p.title,
to: p.slug,
target: '_blank',
href: p.href,
target: p.target,
show: true
})
})
@@ -192,15 +184,6 @@ function getCustomMenu({ collectionData, NOTION_CONFIG }) {
if (menuPages && menuPages.length > 0) {
menuPages.forEach(e => {
e.show = true
if (e?.slug?.indexOf('http') === 0) {
e.target = '_blank'
e.to = e.slug
} else {
e.target = '_self'
if (e?.slug?.indexOf('http') !== 0 && e?.slug?.indexOf('/') !== 0) {
e.to = '/' + e.slug
}
}
if (e.type === BLOG.NOTION_PROPERTY_NAME.type_menu) {
menus.push(e)
} else if (e.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) {