mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 15:09:46 +00:00
game 主题支持PWA
This commit is contained in:
@@ -225,7 +225,7 @@ function getCategoryOptions(schema) {
|
||||
* @param from
|
||||
* @returns {Promise<{title,description,pageCover,icon}>}
|
||||
*/
|
||||
function getSiteInfo({ collection, block }) {
|
||||
function getSiteInfo({ collection, block, NOTION_CONFIG }) {
|
||||
const title = collection?.name?.[0][0] || BLOG.TITLE
|
||||
const description = collection?.description
|
||||
? Object.assign(collection).description[0][0]
|
||||
@@ -233,19 +233,21 @@ function getSiteInfo({ collection, block }) {
|
||||
const pageCover = collection?.cover
|
||||
? mapImgUrl(collection?.cover, block[idToUuid(BLOG.NOTION_PAGE_ID)]?.value)
|
||||
: BLOG.HOME_BANNER_IMAGE
|
||||
let icon = collection?.icon
|
||||
? mapImgUrl(collection?.icon, collection, 'collection')
|
||||
: BLOG.AVATAR
|
||||
|
||||
// 用户头像压缩一下
|
||||
icon = compressImage(icon)
|
||||
let icon = compressImage(
|
||||
collection?.icon
|
||||
? mapImgUrl(collection?.icon, collection, 'collection')
|
||||
: BLOG.AVATAR
|
||||
)
|
||||
// 站点网址
|
||||
const link = NOTION_CONFIG?.LINK || BLOG.LINK
|
||||
|
||||
// 站点图标不能是emoji情
|
||||
// 站点图标不能是emoji
|
||||
const emojiPattern = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g
|
||||
if (!icon || emojiPattern.test(icon)) {
|
||||
icon = BLOG.AVATAR
|
||||
}
|
||||
return { title, description, pageCover, icon }
|
||||
return { title, description, pageCover, icon, link }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +357,6 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
return EmptyData(pageId)
|
||||
}
|
||||
const collection = Object.values(pageRecordMap.collection)[0]?.value || {}
|
||||
const siteInfo = getSiteInfo({ collection, block })
|
||||
const collectionId = rawMetadata?.collection_id
|
||||
const collectionQuery = pageRecordMap.collection_query
|
||||
const collectionView = pageRecordMap.collection_view
|
||||
@@ -422,6 +423,11 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
// 文章计数
|
||||
let postCount = 0
|
||||
|
||||
// 站点配置优先读取配置表格,否则读取blog.config.js 文件
|
||||
const NOTION_CONFIG = (await getConfigMapFromConfigPage(collectionData)) || {}
|
||||
|
||||
const siteInfo = getSiteInfo({ collection, block })
|
||||
|
||||
// 查找所有的Post和Page
|
||||
const allPages = collectionData.filter(post => {
|
||||
if (post?.type === 'Post' && post.status === 'Published') {
|
||||
@@ -435,9 +441,6 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
|
||||
)
|
||||
})
|
||||
|
||||
// 站点配置优先读取配置表格,否则读取blog.config.js 文件
|
||||
const NOTION_CONFIG = (await getConfigMapFromConfigPage(collectionData)) || {}
|
||||
|
||||
// Sort by date
|
||||
if (BLOG.POSTS_SORT_BY === 'date') {
|
||||
allPages.sort((a, b) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 封装异步加载资源的方法
|
||||
import { memo } from 'react';
|
||||
import { memo } from 'react'
|
||||
|
||||
/**
|
||||
* 判断是否客户端
|
||||
@@ -9,18 +9,18 @@ export const isBrowser = typeof window !== 'undefined'
|
||||
|
||||
/**
|
||||
* 打乱数组
|
||||
* @param {*} array
|
||||
* @returns
|
||||
* @param {*} array
|
||||
* @returns
|
||||
*/
|
||||
export const shuffleArray = (array) => {
|
||||
if (!array) {
|
||||
return []
|
||||
}
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array;
|
||||
export const shuffleArray = array => {
|
||||
if (!array) {
|
||||
return []
|
||||
}
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1))
|
||||
;[array[i], array[j]] = [array[j], array[i]]
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user