mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
内部引用链接可以跳转
This commit is contained in:
@@ -75,8 +75,14 @@ const NotionPage = ({ post }) => {
|
||||
</div>
|
||||
}
|
||||
|
||||
/**
|
||||
* 将id映射成博文内部链接。
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
const mapPageUrl = id => {
|
||||
return 'https://www.notion.so/' + id.replace(/-/g, '')
|
||||
// return 'https://www.notion.so/' + id.replace(/-/g, '')
|
||||
return '/article/' + id.replace(/-/g, '')
|
||||
}
|
||||
|
||||
function getMediumZoomMargin() {
|
||||
|
||||
11
lib/utils.js
11
lib/utils.js
@@ -64,10 +64,19 @@ export function mergeDeep(target, ...sources) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象检查
|
||||
* 是否对象
|
||||
* @param item
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isObject(item) {
|
||||
return (item && typeof item === 'object' && !Array.isArray(item))
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可迭代
|
||||
* @param {*} obj
|
||||
* @returns
|
||||
*/
|
||||
export function isIterable(obj) {
|
||||
return obj != null && typeof obj[Symbol.iterator] === 'function'
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useGlobal } from '@/lib/global'
|
||||
import * as ThemeMap from '@/themes'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面
|
||||
@@ -30,7 +31,7 @@ const Slug = props => {
|
||||
}
|
||||
}, 3000)
|
||||
})
|
||||
const meta = { title: `${props?.siteInfo?.title} | loading` }
|
||||
const meta = { title: `${props?.siteInfo?.title || BLOG.TITLE} | loading` }
|
||||
return <ThemeComponents.LayoutSlug {...props} showArticleInfo={true} meta={meta} />
|
||||
}
|
||||
|
||||
@@ -92,7 +93,9 @@ export async function getStaticProps({ params: { slug } }) {
|
||||
const from = `slug-props-${slug}`
|
||||
const props = await getGlobalNotionData({ from, pageType: ['Post'] })
|
||||
const allPosts = props.allPosts
|
||||
props.post = props.allPosts.find(p => p.slug === slug)
|
||||
props.post = props.allPosts.find((p) => {
|
||||
return p.slug === slug || p.id === idToUuid(slug)
|
||||
})
|
||||
if (!props.post) {
|
||||
return { props, revalidate: 1 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user