diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index 7211c31e..e06553eb 100755 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -273,10 +273,15 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { const viewIds = rawMetadata?.view_ids const collectionData = [] + const pageIds = getAllPageIds(collectionQuery, collectionId, collectionView, viewIds) if (pageIds?.length === 0) { console.error('获取到的文章列表为空,请检查notion模板', collectionQuery, collection, collectionView, viewIds, pageRecordMap) + } else { + console.log('有效Page数量', pageIds?.length) } + + // 获取每篇文章基础数据 for (let i = 0; i < pageIds.length; i++) { const id = pageIds[i] const value = block[id]?.value @@ -291,7 +296,8 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) { } continue } - const properties = (await getPageProperties(id, block[id].value, schema, null, getTagOptions(schema))) || null + + const properties = (await getPageProperties(id, value, schema, null, getTagOptions(schema))) || null if (properties) { collectionData.push(properties) } diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js index 92a94342..5caf9368 100644 --- a/lib/notion/getPageProperties.js +++ b/lib/notion/getPageProperties.js @@ -90,9 +90,10 @@ export default async function getPageProperties(id, value, schema, authToken, ta properties.lastEditedDate = new Date(value?.last_edited_time) properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), BLOG.LANG) properties.fullWidth = value.format?.page_full_width ?? false - properties.pageIcon = mapImgUrl(value.value?.format?.page_icon, value.value) ?? '' - properties.pageCover = mapImgUrl(value.value?.format?.page_cover, value.value) ?? '' - properties.pageCoverThumbnail = mapImgUrl(value.value?.format?.page_cover, value.value, 'block', 'pageCoverThumbnail') ?? '' + properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? '' + properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? '' + properties.pageCoverThumbnail = mapImgUrl(value?.format?.page_cover, value, 'block', 'pageCoverThumbnail') ?? '' + properties.content = value.content ?? [] properties.tagItems = properties?.tags?.map(tag => { return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' } diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js index 7b8bf01e..a78ade6b 100644 --- a/lib/notion/getPostBlocks.js +++ b/lib/notion/getPostBlocks.js @@ -61,6 +61,7 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) { const authToken = BLOG.NOTION_ACCESS_TOKEN || null const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) const pageData = await api.getPage(id) + // console.log('stringfy', JSON.stringify(pageData)) console.info('[响应成功]:', `from:${from}`) return pageData } catch (e) { diff --git a/themes/example/index.js b/themes/example/index.js index fde016f7..a3aa7729 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -49,9 +49,9 @@ const LayoutBase = props => { slotTop =
#{tag}
} else if (props.slotTop) { slotTop = props.slotTop - } else if (router.route==='/search'){ - // 嵌入一个搜索框在顶部 - slotTop =
+ } else if (router.route === '/search') { + // 嵌入一个搜索框在顶部 + slotTop =
} // 增加一个状态以触发 Transition 组件的动画 @@ -136,7 +136,6 @@ const LayoutIndex = props => { * @returns */ const LayoutPostList = props => { - return ( <> {siteConfig('POST_LIST_STYLE') === 'page' ? : } diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index ccef346b..579796f8 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -31,7 +31,6 @@ import { Transition } from '@headlessui/react' import { Style } from './style' import CommonHead from '@/components/CommonHead' import BlogArchiveItem from './components/BlogArchiveItem' -import BlogPostListPage from './components/BlogPostListPage' import Link from 'next/link' import dynamic from 'next/dynamic' import { siteConfig } from '@/lib/config' diff --git a/themes/heo/index.js b/themes/heo/index.js index f81fb21d..98fa4b6d 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -59,7 +59,7 @@ const LayoutBase = props => { const { fullWidth } = useGlobal() const router = useRouter() console.log(router) - + const headerSlot = (
{/* 顶部导航 */} @@ -67,11 +67,12 @@ const LayoutBase = props => { {/* 通知横幅 */} - {router.route==='/' ? <> + {router.route === '/' + ? <> - : null} + : null}
@@ -159,7 +160,6 @@ const LayoutIndex = props => { * @returns */ const LayoutPostList = props => { - return (
{/* 文章分类条 */} @@ -184,7 +184,7 @@ const LayoutSearch = props => { const { keyword } = props const router = useRouter() const currentSearch = keyword || router?.query?.s - + useEffect(() => { // 高亮搜索结果 if (currentSearch) { @@ -270,7 +270,6 @@ const LayoutSlug = props => { setHasCode(hasCode) }, []) - const commentEnable = siteConfig('COMMENT_TWIKOO_ENV_ID') || siteConfig('COMMENT_WALINE_SERVER_URL') || siteConfig('COMMENT_VALINE_APP_ID') || siteConfig('COMMENT_GISCUS_REPO') || siteConfig('COMMENT_CUSDIS_APP_ID') || siteConfig('COMMENT_UTTERRANCES_REPO') || siteConfig('COMMENT_GITALK_CLIENT_ID') || siteConfig('COMMENT_WEBMENTION_ENABLE') @@ -428,7 +427,6 @@ const LayoutCategoryIndex = props => { const { categoryOptions } = props const { locale } = useGlobal() - return (
diff --git a/themes/hexo/components/TocDrawer.js b/themes/hexo/components/TocDrawer.js index 20c1941b..a939814d 100644 --- a/themes/hexo/components/TocDrawer.js +++ b/themes/hexo/components/TocDrawer.js @@ -21,7 +21,7 @@ const TocDrawer = ({ post, cRef }) => { } return <>
- {/* 侧边菜单 */} + {/* 悬浮目录 */}
useContext(ThemeGlobalHexo) @@ -46,14 +45,19 @@ export const useHexoGlobal = () => useContext(ThemeGlobalHexo) * @constructor */ const LayoutBase = props => { - const { post , children, slotTop, meta, className } = props + const { post, children, slotTop, meta, className } = props const { onLoading, fullWidth } = useGlobal() const router = useRouter() const headerSlot = post - ? : (router.route==='/' && siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) - ? : null) - + ? + : (router.route === '/' && siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) + ? + : null) + + const drawerRight = useRef(null) + const tocRef = isBrowser ? document.getElementById('article-wrapper') : null + const floatSlot = <> {post?.toc?.length > 1 &&
{
+
+ +
+ {/* 悬浮菜单 */} @@ -141,7 +149,7 @@ const LayoutBase = props => { * @returns */ const LayoutIndex = (props) => { - return + return } /** @@ -217,8 +225,6 @@ const LayoutArchive = (props) => { */ const LayoutSlug = props => { const { post, lock, validPassword } = props - const drawerRight = useRef(null) - const tocRef = isBrowser ? document.getElementById('article-wrapper') : null return ( <> @@ -252,10 +258,6 @@ const LayoutSlug = props => {
}
-
- -
- ) } diff --git a/themes/matery/index.js b/themes/matery/index.js index ce099cd7..a71b3872 100644 --- a/themes/matery/index.js +++ b/themes/matery/index.js @@ -43,9 +43,10 @@ const LayoutBase = props => { const { children, meta, siteInfo, post } = props const { onLoading, fullWidth } = useGlobal() const router = useRouter() - const containerSlot= router.route==='/' ? : - const headerSlot= siteConfig('MATERY_HOME_BANNER_ENABLE', null, CONFIG) && router.route==='/' - ? : (post && !fullWidth ? : null) + const containerSlot = router.route === '/' ? : + const headerSlot = siteConfig('MATERY_HOME_BANNER_ENABLE', null, CONFIG) && router.route === '/' + ? + : (post && !fullWidth ? : null) const floatRightBottom = post ? : null @@ -198,7 +199,7 @@ const LayoutArchive = (props) => { const LayoutSlug = props => { const { post, lock, validPassword } = props const { fullWidth } = useGlobal() - + return (<>
diff --git a/themes/nav/index.js b/themes/nav/index.js index b09fe080..8b4edde2 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -25,7 +25,6 @@ import { ArticleLock } from './components/ArticleLock' import { Transition } from '@headlessui/react' import { Style } from './style' import CommonHead from '@/components/CommonHead' -import BlogArchiveItem from './components/BlogArchiveItem' import BlogPostListAll from './components/BlogPostListAll' import BlogPostCard from './components/BlogPostCard' import Link from 'next/link' @@ -271,14 +270,7 @@ const LayoutSearch = (props) => { * @returns */ const LayoutArchive = (props) => { - return
- // const { archivePosts } = props - - return <> -
- {Object.keys(archivePosts)?.map(archiveTitle => )} -
- + return <> } /** @@ -325,27 +317,7 @@ const LayoutCategoryIndex = (props) => { * 标签列表 */ const LayoutTagIndex = (props) => { - return
- // const { tagOptions } = props - // const { locale } = useGlobal() - - return <> -
-
- - {locale.COMMON.TAGS}: -
-
- {tagOptions?.map(tag => { - return ( -
- -
- ) - })} -
-
- + return <> } export { diff --git a/themes/next/index.js b/themes/next/index.js index 35a6091a..c2fc59d7 100644 --- a/themes/next/index.js +++ b/themes/next/index.js @@ -71,7 +71,7 @@ const LayoutBase = (props) => { const drawerRight = useRef(null) const floatSlot =
{ - drawerRight?.current?.handleSwitchVisible() + drawerRight?.current?.handleSwitchVisible() }} />
const tocRef = isBrowser ? document.getElementById('article-wrapper') : null @@ -114,7 +114,7 @@ const LayoutBase = (props) => { {/* 右侧栏样式 */} {siteConfig('NEXT_RIGHT_BAR', null, CONFIG) && } - + {/* 悬浮目录按钮 */} @@ -342,5 +342,5 @@ export { Layout404, LayoutCategoryIndex, LayoutPostList, - LayoutTagIndex, + LayoutTagIndex } diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js index 83650ae8..d9575aaf 100644 --- a/themes/nobelium/index.js +++ b/themes/nobelium/index.js @@ -37,13 +37,13 @@ export const useNobeliumGlobal = () => useContext(ThemeGlobalNobelium) * @constructor */ const LayoutBase = props => { - const { children, post, meta } = props + const { children, post, meta } = props const fullWidth = post?.fullWidth ?? false const { onLoading } = useGlobal() const searchModal = useRef(null) // 在列表中进行实时过滤 const [filterKey, setFilterKey] = useState('') - const topSlot= + const topSlot = return ( @@ -116,7 +116,7 @@ const LayoutIndex = props => { * @returns */ const LayoutPostList = props => { - const { posts, topSlot,tag } = props + const { posts, topSlot, tag } = props const { filterKey } = useNobeliumGlobal() let filteredBlogPosts = [] if (filterKey && posts) { @@ -160,7 +160,7 @@ const LayoutSearch = props => { }, []) // 在列表中进行实时过滤 - const {filterKey} = useNobeliumGlobal() + const { filterKey } = useNobeliumGlobal() let filteredBlogPosts = [] if (filterKey && posts) { filteredBlogPosts = posts.filter(post => { diff --git a/themes/simple/index.js b/themes/simple/index.js index c4a705a7..0ed8a5f2 100644 --- a/themes/simple/index.js +++ b/themes/simple/index.js @@ -290,5 +290,5 @@ export { Layout404, LayoutCategoryIndex, LayoutPostList, - LayoutTagIndex, + LayoutTagIndex }