mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-07 15:10:32 +00:00
video-size
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import BLOG from '@/blog.config'
|
import BLOG from '@/blog.config'
|
||||||
import { idToUuid } from 'notion-utils'
|
import { idToUuid } from 'notion-utils'
|
||||||
|
import { defaultMapImageUrl } from 'react-notion-x'
|
||||||
import formatDate from '../utils/formatDate'
|
import formatDate from '../utils/formatDate'
|
||||||
import { getPostBlocks } from './getPostBlocks'
|
import { getPostBlocks } from './getPostBlocks'
|
||||||
import { defaultMapImageUrl } from 'react-notion-x'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据页面ID获取内容
|
* 根据页面ID获取内容
|
||||||
@@ -23,11 +23,22 @@ export async function getPost(pageId) {
|
|||||||
tags: [],
|
tags: [],
|
||||||
title: postInfo?.properties?.title?.[0],
|
title: postInfo?.properties?.title?.[0],
|
||||||
status: 'Published',
|
status: 'Published',
|
||||||
createdTime: formatDate(new Date(postInfo.created_time).toString(), BLOG.LANG),
|
createdTime: formatDate(
|
||||||
lastEditedDay: formatDate(new Date(postInfo?.last_edited_time).toString(), BLOG.LANG),
|
new Date(postInfo.created_time).toString(),
|
||||||
fullWidth: postInfo?.fullWidth,
|
BLOG.LANG
|
||||||
page_cover: getPageCover(postInfo),
|
),
|
||||||
date: { start_date: formatDate(new Date(postInfo?.last_edited_time).toString(), BLOG.LANG) },
|
lastEditedDay: formatDate(
|
||||||
|
new Date(postInfo?.last_edited_time).toString(),
|
||||||
|
BLOG.LANG
|
||||||
|
),
|
||||||
|
fullWidth: postInfo?.fullWidth || false,
|
||||||
|
page_cover: getPageCover(postInfo) || BLOG.HOME_BANNER_IMAGE,
|
||||||
|
date: {
|
||||||
|
start_date: formatDate(
|
||||||
|
new Date(postInfo?.last_edited_time).toString(),
|
||||||
|
BLOG.LANG
|
||||||
|
)
|
||||||
|
},
|
||||||
blockMap
|
blockMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +47,7 @@ function getPageCover(postInfo) {
|
|||||||
const pageCover = postInfo.format?.page_cover
|
const pageCover = postInfo.format?.page_cover
|
||||||
if (pageCover) {
|
if (pageCover) {
|
||||||
if (pageCover.startsWith('/')) return BLOG.NOTION_HOST + pageCover
|
if (pageCover.startsWith('/')) return BLOG.NOTION_HOST + pageCover
|
||||||
if (pageCover.startsWith('http')) return defaultMapImageUrl(pageCover, postInfo)
|
if (pageCover.startsWith('http'))
|
||||||
|
return defaultMapImageUrl(pageCover, postInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,13 @@ import { mapImgUrl } from './mapImage'
|
|||||||
* @param {*} tagOptions
|
* @param {*} tagOptions
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export default async function getPageProperties(id, value, schema, authToken, tagOptions) {
|
export default async function getPageProperties(
|
||||||
|
id,
|
||||||
|
value,
|
||||||
|
schema,
|
||||||
|
authToken,
|
||||||
|
tagOptions
|
||||||
|
) {
|
||||||
const rawProperties = Object.entries(value?.properties || [])
|
const rawProperties = Object.entries(value?.properties || [])
|
||||||
const excludeProperties = ['date', 'select', 'multi_select', 'person']
|
const excludeProperties = ['date', 'select', 'multi_select', 'person']
|
||||||
const properties = {}
|
const properties = {}
|
||||||
@@ -49,7 +55,8 @@ export default async function getPageProperties(id, value, schema, authToken, ta
|
|||||||
if (rawUsers[i][0][1]) {
|
if (rawUsers[i][0][1]) {
|
||||||
const userId = rawUsers[i][0]
|
const userId = rawUsers[i][0]
|
||||||
const res = await api.getUsers(userId)
|
const res = await api.getUsers(userId)
|
||||||
const resValue = res?.recordMapWithRoles?.notion_user?.[userId[1]]?.value
|
const resValue =
|
||||||
|
res?.recordMapWithRoles?.notion_user?.[userId[1]]?.value
|
||||||
const user = {
|
const user = {
|
||||||
id: resValue?.id,
|
id: resValue?.id,
|
||||||
first_name: resValue?.given_name,
|
first_name: resValue?.given_name,
|
||||||
@@ -72,7 +79,8 @@ export default async function getPageProperties(id, value, schema, authToken, ta
|
|||||||
const fieldNames = BLOG.NOTION_PROPERTY_NAME
|
const fieldNames = BLOG.NOTION_PROPERTY_NAME
|
||||||
if (fieldNames) {
|
if (fieldNames) {
|
||||||
Object.keys(fieldNames).forEach(key => {
|
Object.keys(fieldNames).forEach(key => {
|
||||||
if (fieldNames[key] && properties[fieldNames[key]]) properties[key] = properties[fieldNames[key]]
|
if (fieldNames[key] && properties[fieldNames[key]])
|
||||||
|
properties[key] = properties[fieldNames[key]]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,25 +92,41 @@ export default async function getPageProperties(id, value, schema, authToken, ta
|
|||||||
// 映射值:用户个性化type和status字段的下拉框选项,在此映射回代码的英文标识
|
// 映射值:用户个性化type和status字段的下拉框选项,在此映射回代码的英文标识
|
||||||
mapProperties(properties)
|
mapProperties(properties)
|
||||||
|
|
||||||
properties.publishDate = new Date(properties?.date?.start_date || value.created_time).getTime()
|
properties.publishDate = new Date(
|
||||||
|
properties?.date?.start_date || value.created_time
|
||||||
|
).getTime()
|
||||||
properties.publishDay = formatDate(properties.publishDate, BLOG.LANG)
|
properties.publishDay = formatDate(properties.publishDate, BLOG.LANG)
|
||||||
properties.lastEditedDate = new Date(value?.last_edited_time)
|
properties.lastEditedDate = new Date(value?.last_edited_time)
|
||||||
properties.lastEditedDay = formatDate(new Date(value?.last_edited_time), BLOG.LANG)
|
properties.lastEditedDay = formatDate(
|
||||||
properties.fullWidth = value.format?.page_full_width ?? false
|
new Date(value?.last_edited_time),
|
||||||
|
BLOG.LANG
|
||||||
|
)
|
||||||
|
properties.fullWidth = value?.format?.page_full_width ?? false
|
||||||
properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? ''
|
properties.pageIcon = mapImgUrl(value?.format?.page_icon, value) ?? ''
|
||||||
properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? ''
|
properties.pageCover = mapImgUrl(value?.format?.page_cover, value) ?? ''
|
||||||
properties.pageCoverThumbnail = mapImgUrl(value?.format?.page_cover, value, 'block', 'pageCoverThumbnail') ?? ''
|
properties.pageCoverThumbnail =
|
||||||
|
mapImgUrl(
|
||||||
|
value?.format?.page_cover,
|
||||||
|
value,
|
||||||
|
'block',
|
||||||
|
'pageCoverThumbnail'
|
||||||
|
) ?? ''
|
||||||
properties.ext = converToJSON(properties?.ext)
|
properties.ext = converToJSON(properties?.ext)
|
||||||
properties.content = value.content ?? []
|
properties.content = value.content ?? []
|
||||||
properties.tagItems =
|
properties.tagItems =
|
||||||
properties?.tags?.map(tag => {
|
properties?.tags?.map(tag => {
|
||||||
return { name: tag, color: tagOptions?.find(t => t.value === tag)?.color || 'gray' }
|
return {
|
||||||
|
name: tag,
|
||||||
|
color: tagOptions?.find(t => t.value === tag)?.color || 'gray'
|
||||||
|
}
|
||||||
}) || []
|
}) || []
|
||||||
delete properties.content
|
delete properties.content
|
||||||
|
|
||||||
// 处理URL
|
// 处理URL
|
||||||
if (properties.type === 'Post') {
|
if (properties.type === 'Post') {
|
||||||
properties.slug = BLOG.POST_URL_PREFIX ? generateCustomizeUrl(properties) : properties.slug ?? properties.id
|
properties.slug = BLOG.POST_URL_PREFIX
|
||||||
|
? generateCustomizeUrl(properties)
|
||||||
|
: properties.slug ?? properties.id
|
||||||
} else if (properties.type === 'Page') {
|
} else if (properties.type === 'Page') {
|
||||||
properties.slug = properties.slug ?? properties.id
|
properties.slug = properties.slug ?? properties.id
|
||||||
} else if (properties.type === 'Menu' || properties.type === 'SubMenu') {
|
} else if (properties.type === 'Menu' || properties.type === 'SubMenu') {
|
||||||
@@ -113,12 +137,17 @@ export default async function getPageProperties(id, value, schema, authToken, ta
|
|||||||
|
|
||||||
// 开启伪静态路径
|
// 开启伪静态路径
|
||||||
if (JSON.parse(BLOG.PSEUDO_STATIC)) {
|
if (JSON.parse(BLOG.PSEUDO_STATIC)) {
|
||||||
if (!properties?.slug?.endsWith('.html') && !properties?.slug?.startsWith('http')) {
|
if (
|
||||||
|
!properties?.slug?.endsWith('.html') &&
|
||||||
|
!properties?.slug?.startsWith('http')
|
||||||
|
) {
|
||||||
properties.slug += '.html'
|
properties.slug += '.html'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 密码字段md5
|
// 密码字段md5
|
||||||
properties.password = properties.password ? md5(properties.slug + properties.password) : ''
|
properties.password = properties.password
|
||||||
|
? md5(properties.slug + properties.password)
|
||||||
|
: ''
|
||||||
return properties
|
return properties
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +206,10 @@ function generateCustomizeUrl(postProperties) {
|
|||||||
fullPrefix += formatPostCreatedDate.getUTCFullYear()
|
fullPrefix += formatPostCreatedDate.getUTCFullYear()
|
||||||
} else if (pattern === '%month%' && postProperties?.publishDay) {
|
} else if (pattern === '%month%' && postProperties?.publishDay) {
|
||||||
const formatPostCreatedDate = new Date(postProperties?.publishDay)
|
const formatPostCreatedDate = new Date(postProperties?.publishDay)
|
||||||
fullPrefix += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(2, 0)
|
fullPrefix += String(formatPostCreatedDate.getUTCMonth() + 1).padStart(
|
||||||
|
2,
|
||||||
|
0
|
||||||
|
)
|
||||||
} else if (pattern === '%day%' && postProperties?.publishDay) {
|
} else if (pattern === '%day%' && postProperties?.publishDay) {
|
||||||
const formatPostCreatedDate = new Date(postProperties?.publishDay)
|
const formatPostCreatedDate = new Date(postProperties?.publishDay)
|
||||||
fullPrefix += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0)
|
fullPrefix += String(formatPostCreatedDate.getUTCDate()).padStart(2, 0)
|
||||||
|
|||||||
@@ -2064,7 +2064,8 @@ code.language-mermaid {
|
|||||||
border: 1px solid var(#eee) !important;
|
border: 1px solid var(#eee) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 竖屏视频高度bug */
|
/* 视频尺寸bug */
|
||||||
figure.notion-asset-wrapper.notion-asset-wrapper-video > div {
|
figure.notion-asset-wrapper.notion-asset-wrapper-video > div {
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user