custom table options

This commit is contained in:
tangly1024.com
2023-02-13 18:48:20 +08:00
parent d3255ae625
commit 4c5c47d71e

View File

@@ -61,7 +61,7 @@ export default async function getPageProperties(id, block, schema, authToken, ta
}
}
// 设置自定义字段
// 映射键:用户自定义表头名
const fieldNames = BLOG.NOTION_PROPERTY_NAME
if (fieldNames) {
Object.keys(fieldNames).forEach(key => {
@@ -73,24 +73,10 @@ export default async function getPageProperties(id, block, schema, authToken, ta
properties.type = properties.type?.[0]
properties.status = properties.status?.[0]
// 映射值用户个性化type和status字段,在此映射回代码的英文标识
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
properties.type = 'Post'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_page) {
properties.type = 'Page'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_notice) {
properties.type = 'Notice'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_publish) {
properties.status = 'Published'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_invisible) {
properties.status = 'Invisible'
}
// 映射值用户个性化type和status字段的下拉框选项,在此映射回代码的英文标识
mapProperties(properties)
if (properties.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
if (properties.type === 'Post') {
properties.slug = BLOG.POST_URL_PREFIX ? (BLOG.POST_URL_PREFIX + '/' + (properties.slug ?? properties.id)) : (properties.slug ?? properties.id)
} else {
properties.slug = (properties.slug ?? properties.id)
@@ -139,3 +125,21 @@ function getImageUrl(imgObj, blockVal) {
// 其他图片链接 或 emoji
return imgObj
}
function mapProperties(properties) {
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_post) {
properties.type = 'Post'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_page) {
properties.type = 'Page'
}
if (properties?.type === BLOG.NOTION_PROPERTY_NAME.type_notice) {
properties.type = 'Notice'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_publish) {
properties.status = 'Published'
}
if (properties?.status === BLOG.NOTION_PROPERTY_NAME.status_invisible) {
properties.status = 'Invisible'
}
}