mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 15:09:46 +00:00
最后更新时间
This commit is contained in:
@@ -32,7 +32,9 @@ export default {
|
||||
ARTICLE_DETAIL: 'Article Details',
|
||||
PASSWORD_ERROR: 'Password Error!',
|
||||
ARTICLE_LOCK_TIPS: 'Please Enter the password:',
|
||||
SUBMIT: 'Submit'
|
||||
SUBMIT: 'Submit',
|
||||
POST_TIME: 'Post on',
|
||||
LAST_EDITED_TIME: 'Last edited time'
|
||||
},
|
||||
PAGINATION: {
|
||||
PREV: 'Prev',
|
||||
|
||||
@@ -34,7 +34,9 @@ export default {
|
||||
ARTICLE_DETAIL: '文章详情',
|
||||
PASSWORD_ERROR: '密码错误!',
|
||||
ARTICLE_LOCK_TIPS: '文章已上锁,请输入访问密码',
|
||||
SUBMIT: '提交'
|
||||
SUBMIT: '提交',
|
||||
POST_TIME: '发布于',
|
||||
LAST_EDITED_TIME: '最后更新'
|
||||
},
|
||||
PAGINATION: {
|
||||
PREV: '上一页',
|
||||
|
||||
@@ -34,7 +34,9 @@ export default {
|
||||
ARTICLE_DETAIL: '完整文章',
|
||||
PASSWORD_ERROR: '密碼錯誤!',
|
||||
ARTICLE_LOCK_TIPS: '文章已上鎖,請輸入訪問密碼',
|
||||
SUBMIT: '提交'
|
||||
SUBMIT: '提交',
|
||||
POST_TIME: '发布于',
|
||||
LAST_EDITED_TIME: '最后更新日期'
|
||||
},
|
||||
PAGINATION: {
|
||||
PREV: '上一頁',
|
||||
|
||||
@@ -2,6 +2,7 @@ import BLOG from '@/blog.config'
|
||||
import getAllPageIds from './getAllPageIds'
|
||||
import getPageProperties from './getPageProperties'
|
||||
import { defaultMapImageUrl } from 'react-notion-x'
|
||||
import formatDate from '@/lib/formatDate'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
import { delCacheData } from '@/lib/cache/cache_manager'
|
||||
|
||||
@@ -12,7 +13,7 @@ import { delCacheData } from '@/lib/cache/cache_manager'
|
||||
* @param pageType 页面类型数组 ['Post','Page']
|
||||
* @returns {Promise<*[]>}
|
||||
*/
|
||||
export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
export async function getAllPosts({ notionPageData, from, pageType }) {
|
||||
if (!notionPageData) {
|
||||
notionPageData = await getNotionPageData({ from })
|
||||
}
|
||||
@@ -31,8 +32,8 @@ export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
const id = pageIds[i]
|
||||
const properties = (await getPageProperties(id, pageBlock, schema)) || null
|
||||
properties.slug = properties.slug ?? properties.id
|
||||
properties.createdTime = new Date(pageBlock[id].value?.created_time).toString() // FIXME 似乎没有created_time 字段了
|
||||
properties.lastEditedTime = new Date(pageBlock[id].value?.last_edited_time).toString() // FIXME 似乎没有created_time 字段了
|
||||
properties.createdTime = formatDate(new Date(pageBlock[id].value?.created_time).toString(), BLOG.LANG)
|
||||
properties.lastEditedTime = formatDate(new Date(pageBlock[id].value?.last_edited_time).toString(), BLOG.LANG)
|
||||
properties.fullWidth = pageBlock[id].value?.format?.page_full_width ?? false
|
||||
properties.page_cover = getPostCover(id, pageBlock) ?? null
|
||||
properties.content = pageBlock[id].value?.content ?? []
|
||||
@@ -65,7 +66,7 @@ export async function getAllPosts ({ notionPageData, from, pageType }) {
|
||||
}
|
||||
|
||||
// 从Block获取封面图;优先取PageCover,否则取内容图片
|
||||
function getPostCover (id, block) {
|
||||
function getPostCover(id, block) {
|
||||
const pageCover = block[id].value?.format?.page_cover
|
||||
if (pageCover) {
|
||||
if (pageCover.startsWith('/')) return 'https://www.notion.so' + pageCover
|
||||
@@ -78,7 +79,7 @@ function getPostCover (id, block) {
|
||||
* @param {*} param0
|
||||
* @returns
|
||||
*/
|
||||
export async function getAllPostCount ({ notionPageData, from }) {
|
||||
export async function getAllPostCount({ notionPageData, from }) {
|
||||
if (!notionPageData) {
|
||||
notionPageData = await getNotionPageData({ from })
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getTextContent, getDateValue } from 'notion-utils'
|
||||
import { NotionAPI } from 'notion-client'
|
||||
|
||||
async function getPageProperties (id, block, schema, authToken) {
|
||||
async function getPageProperties(id, block, schema, authToken) {
|
||||
const rawProperties = Object.entries(block?.[id]?.value?.properties || [])
|
||||
const excludeProperties = ['date', 'select', 'multi_select', 'person']
|
||||
const properties = {}
|
||||
|
||||
@@ -2,7 +2,7 @@ import BLOG from '@/blog.config'
|
||||
import { NotionAPI } from 'notion-client'
|
||||
import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
||||
|
||||
export async function getPostBlocks (id, from, slice, retryCount = 3) {
|
||||
export async function getPostBlocks(id, from, slice, retryCount = 3) {
|
||||
const cacheKey = 'page_block_' + id
|
||||
let pageBlock = await getDataFromCache(cacheKey)
|
||||
if (pageBlock) {
|
||||
@@ -32,13 +32,13 @@ export async function getPostBlocks (id, from, slice, retryCount = 3) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取到的blockMap删除不需要的字段
|
||||
* @param {*} id 页面ID
|
||||
* @param {*} pageBlock 页面元素
|
||||
* @param {*} slice 截取数量
|
||||
* @returns
|
||||
*/
|
||||
function filterPostBlocks (id, pageBlock, slice) {
|
||||
function filterPostBlocks(id, pageBlock, slice) {
|
||||
const clonePageBlock = deepClone(pageBlock)
|
||||
let count = 0
|
||||
|
||||
@@ -51,8 +51,6 @@ function filterPostBlocks (id, pageBlock, slice) {
|
||||
count++
|
||||
delete b?.role
|
||||
delete b?.value?.version
|
||||
delete b?.value?.created_time
|
||||
delete b?.value?.last_edited_time
|
||||
delete b?.value?.created_by_table
|
||||
delete b?.value?.created_by_id
|
||||
delete b?.value?.last_edited_by_table
|
||||
@@ -67,7 +65,7 @@ function filterPostBlocks (id, pageBlock, slice) {
|
||||
return clonePageBlock
|
||||
}
|
||||
|
||||
function deepClone (obj) {
|
||||
function deepClone(obj) {
|
||||
const newObj = Array.isArray(obj) ? [] : {}
|
||||
if (obj && typeof obj === 'object') {
|
||||
for (const key in obj) {
|
||||
|
||||
Reference in New Issue
Block a user