mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
修复静态页面开启时,文章url前缀设为空无法访问的bug
This commit is contained in:
@@ -205,9 +205,10 @@ const BLOG = {
|
||||
'link,wechat,qq,weibo,email,facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin', // 分享的服務,按顺序显示,逗号隔开
|
||||
// 所有支持的分享服务:link(复制链接),wechat(微信),qq,weibo(微博),email(邮件),facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin,vkshare,okshare,tumblr,livejournal,mailru,viber,workplace,pocket,instapaper,hatena
|
||||
|
||||
POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX || 'article',
|
||||
// 文章URL前缀
|
||||
POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX ?? 'article',
|
||||
// POST类型文章的默认路径前缀,例如默认POST类型的路径是 /article/[slug]
|
||||
// 如果此项配置为 '' 空, 则文章将没有前缀路径,使用场景: 希望文章前缀路径为 /post 的情况 支持多级
|
||||
// 如果此项配置为 '' 空, 则文章将没有前缀路径
|
||||
// 支援類似 WP 可自訂文章連結格式的功能:https://wordpress.org/documentation/article/customize-permalinks/,目前只先實作 %year%/%month%/%day%
|
||||
// 例:如想連結改成前綴 article + 時間戳記,可變更為: 'article/%year%/%month%/%day%'
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
|
||||
return null
|
||||
}
|
||||
|
||||
// 特殊配置处理;某些配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
|
||||
// 特殊配置处理;以下配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
|
||||
switch (key) {
|
||||
case 'NEXT_REVALIDATE_SECOND':
|
||||
case 'POST_RECOMMEND_COUNT':
|
||||
|
||||
@@ -187,7 +187,7 @@ export function adjustPageProperties(properties, NOTION_CONFIG) {
|
||||
}
|
||||
|
||||
// 开启伪静态路径
|
||||
if (JSON.parse(NOTION_CONFIG?.PSEUDO_STATIC || BLOG.PSEUDO_STATIC)) {
|
||||
if (siteConfig('PSEUDO_STATIC', false, NOTION_CONFIG)) {
|
||||
if (
|
||||
!properties?.href?.endsWith('.html') &&
|
||||
!properties?.href?.startsWith('http')
|
||||
|
||||
@@ -124,7 +124,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
|
||||
let fullSlug = prefix
|
||||
const from = `slug-props-${fullSlug}`
|
||||
const props = await getGlobalData({ from, locale })
|
||||
if (siteConfig('PSEUDO_STATIC', BLOG.PSEUDO_STATIC, props.NOTION_CONFIG)) {
|
||||
if (siteConfig('PSEUDO_STATIC', false, props.NOTION_CONFIG)) {
|
||||
if (!fullSlug.endsWith('.html')) {
|
||||
fullSlug += '.html'
|
||||
}
|
||||
@@ -134,7 +134,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
|
||||
props.post = props?.allPages?.find(p => {
|
||||
return (
|
||||
p.type.indexOf('Menu') < 0 &&
|
||||
(p.slug === fullSlug || p.id === idToUuid(fullSlug))
|
||||
(p.slug === prefix || p.id === idToUuid(prefix))
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user