Skip to content
Open
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ The configuration priority is:
2. Environment Variables
3. blog.config.js (lowest)

[fork]: https://github.com/tangly1024/NotionNext/fork
[pr]: https://github.com/tangly1024/NotionNext/compare
[fork]: https://github.com/LeoYoung-code/fork
[pr]: https://github.com/LeoYoung-code/compare
[next.js]: https://github.com/vercel/next.js
[themes-dir]: themes
[example]: themes/example
Expand Down
579 changes: 0 additions & 579 deletions blog.config.js

This file was deleted.

225 changes: 225 additions & 0 deletions lib/db/getSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,228 @@ export function getNavPages({ allPages }) {
ext: item.ext || {}
}))
}

/**
* 获取公告
*/
async function getNotice(post) {
if (!post) {
return null
}

post.blockMap = await getPage(post.id, 'data-notice')
return post
}

// 没有数据时返回
const EmptyData = pageId => {
const empty = {
notice: null,
siteInfo: getSiteInfo({}),
allPages: [
{
id: 1,
title: `无法获取Notion数据,请检查Notion_ID: \n 当前 ${pageId}`,
summary:
'访问文档获取帮助→ https://github.com/LeoYoung-code/article/vercel-deploy-notion-next',
status: 'Published',
type: 'Post',
slug: '13a171332816461db29d50e9f575b00d',
pageCoverThumbnail: BLOG.HOME_BANNER_IMAGE,
date: {
start_date: '2023-04-24',
lastEditedDay: '2023-04-24',
tagItems: []
}
}
],
allNavPages: [],
collection: [],
collectionQuery: {},
collectionId: null,
collectionView: {},
viewIds: [],
block: {},
schema: {},
tagOptions: [],
categoryOptions: [],
rawMetadata: {},
customNav: [],
customMenu: [],
postCount: 1,
pageIds: [],
latestPosts: []
}
return empty
}

/**
* 调用NotionAPI获取Page数据
* @returns {Promise<JSX.Element|null|*>}
*/
async function getDataBaseInfoByNotionAPI({ pageId, from }) {
console.log('[Fetching Data]', pageId, from)
const pageRecordMap = await getPage(pageId, from)
if (!pageRecordMap) {
console.error('can`t get Notion Data ; Which id is: ', pageId)
return {}
}
pageId = idToUuid(pageId)
let block = pageRecordMap.block || {}
const rawMetadata = block[pageId]?.value
// Check Type Page-Database和Inline-Database
if (
rawMetadata?.type !== 'collection_view_page' &&
rawMetadata?.type !== 'collection_view'
) {
console.error(`pageId "${pageId}" is not a database`)
return EmptyData(pageId)
}
const collection = Object.values(pageRecordMap.collection)[0]?.value || {}
const collectionId = rawMetadata?.collection_id
const collectionQuery = pageRecordMap.collection_query
const collectionView = pageRecordMap.collection_view
const schema = collection?.schema

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)
}

// 抓取主数据库最多抓取1000个blocks,溢出的数block这里统一抓取一遍
const blockIdsNeedFetch = []
for (let i = 0; i < pageIds.length; i++) {
const id = pageIds[i]
const value = block[id]?.value
if (!value) {
blockIdsNeedFetch.push(id)
}
}
const fetchedBlocks = await fetchInBatches(blockIdsNeedFetch)
block = Object.assign({}, block, fetchedBlocks)

// 获取每篇文章基础数据
for (let i = 0; i < pageIds.length; i++) {
const id = pageIds[i]
const value = block[id]?.value || fetchedBlocks[id]?.value
const properties =
(await getPageProperties(
id,
value,
schema,
null,
getTagOptions(schema)
)) || null

if (properties) {
collectionData.push(properties)
}
}

// 站点配置优先读取配置表格,否则读取blog.config.js 文件
const NOTION_CONFIG = (await getConfigMapFromConfigPage(collectionData)) || {}

// 处理每一条数据的字段
collectionData.forEach(function (element) {
adjustPageProperties(element, NOTION_CONFIG)
})

// 站点基础信息
const siteInfo = getSiteInfo({ collection, block, pageId })

// 文章计数
let postCount = 0

// 查找所有的Post和Page
const allPages = collectionData.filter(post => {
if (post?.type === 'Post' && post.status === 'Published') {
postCount++
}
return (
post &&
post?.slug &&
// !post?.slug?.startsWith('http') &&
(post?.status === 'Invisible' || post?.status === 'Published')
)
})

// Sort by date
if (siteConfig('POSTS_SORT_BY', '', NOTION_CONFIG) === 'date') {
allPages.sort((a, b) => {
return b?.publishDate - a?.publishDate
})
}

const notice = await getNotice(
collectionData.filter(post => {
return (
post &&
post?.type &&
post?.type === 'Notice' &&
post.status === 'Published'
)
})?.[0]
)
// 所有分类
const categoryOptions = getAllCategories({
allPages,
categoryOptions: getCategoryOptions(schema)
})
// 所有标签
const tagOptions = getAllTags({
allPages,
tagOptions: getTagOptions(schema),
NOTION_CONFIG
})
// 旧的菜单
const customNav = getCustomNav({
allPages: collectionData.filter(
post => post?.type === 'Page' && post.status === 'Published'
)
})
// 新的菜单
const customMenu = await getCustomMenu({ collectionData, NOTION_CONFIG })
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 6 })
const allNavPages = getNavPages({ allPages })

return {
NOTION_CONFIG,
notice,
siteInfo,
allPages,
allNavPages,
collection,
collectionQuery,
collectionId,
collectionView,
viewIds,
block,
schema,
tagOptions,
categoryOptions,
rawMetadata,
customNav,
customMenu,
postCount,
pageIds,
latestPosts
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/tangly1024/NotionNext.git"
"url": "https://github.com/LeoYoung-code"
},
"author": {
"name": "tangly",
"name": "leoyoung",
"email": "mail@tangly1024.com",
"url": "http://tangly1024.com"
"url": "https://github.com/LeoYoung-code"
},
"scripts": {
"dev": "next dev",
Expand Down Expand Up @@ -71,7 +71,7 @@
"axios": ">=0.21.1"
},
"bugs": {
"url": "https://github.com/tangly/NotionNext/issues",
"url": "https://github.com/LeoYoung-code",
"email": "tlyong1992@hotmail.com"
}
}
Binary file modified public/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/bg_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/gongan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/about/about-image-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/about/about-image-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/article-author-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/article-author-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/article-author-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/article-author-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/bannder-ad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-details-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-footer-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/blog/blog-footer-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions public/images/starter/team/shape-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/team/team-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/team/team-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/team/team-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/testimonials/author-01.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/testimonials/author-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/starter/testimonials/author-03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/testimonial.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/themes-preview/gitbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/images/themes-preview/nav.png
Binary file modified public/images/themes-preview/next.png
Binary file modified public/images/themes-preview/nobelium.png
Binary file modified public/images/themes-preview/simple.png
Binary file modified public/qrcode.png
2 changes: 1 addition & 1 deletion public/svg/zhishixingqiu.svg
2 changes: 1 addition & 1 deletion themes/commerce/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const Footer = props => {
<div className='text-xs text-light-500 dark:text-gray-700'>
Powered by{' '}
<a
href='https://github.com/tangly1024/NotionNext'
href='https://github.com/LeoYoung-code'
className='dark:text-gray-300'>
NotionNext {siteConfig('VERSION')}
</a>
Expand Down
27 changes: 0 additions & 27 deletions themes/example/components/Footer.js

This file was deleted.

55 changes: 0 additions & 55 deletions themes/fukasawa/components/SiteInfo.js

This file was deleted.

2 changes: 1 addition & 1 deletion themes/game/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Footer = props => {
<span className='dark:text-gray-200 no-underline ml-4'>
Powered by
<a
href='https://github.com/tangly1024/NotionNext'
href='https://github.com/LeoYoung-code'
className=' hover:underline'>
{' '}
NotionNext {siteConfig('VERSION')}{' '}
Expand Down
1 change: 1 addition & 0 deletions themes/heo/components/InfoCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function InfoCard(props) {
</div>
</div>


<h2 className='text-3xl font-extrabold mt-3'>{siteConfig('AUTHOR')}</h2>

{/* 公告栏 */}
Expand Down
Loading
Loading