|
1 | 1 | import BLOG from '@/blog.config'
|
2 |
| -import { NotionAPI } from 'notion-client' |
3 | 2 | import { getDataFromCache, setDataToCache } from '@/lib/cache/cache_manager'
|
| 3 | +import { NotionAPI } from 'notion-client' |
4 | 4 | import { deepClone, delay } from '../utils'
|
5 | 5 |
|
6 | 6 | /**
|
@@ -56,10 +56,18 @@ export async function getSingleBlock(id, from) {
|
56 | 56 | */
|
57 | 57 | export async function getPageWithRetry(id, from, retryAttempts = 3) {
|
58 | 58 | if (retryAttempts && retryAttempts > 0) {
|
59 |
| - console.log('[API-->>请求]', `from:${from}`, `id:${id}`, retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '') |
| 59 | + console.log( |
| 60 | + '[API-->>请求]', |
| 61 | + `from:${from}`, |
| 62 | + `id:${id}`, |
| 63 | + retryAttempts < 3 ? `剩余重试次数:${retryAttempts}` : '' |
| 64 | + ) |
60 | 65 | try {
|
61 | 66 | const authToken = BLOG.NOTION_ACCESS_TOKEN || null
|
62 |
| - const api = new NotionAPI({ authToken, userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) |
| 67 | + const api = new NotionAPI({ |
| 68 | + authToken, |
| 69 | + userTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone |
| 70 | + }) |
63 | 71 | const start = new Date().getTime()
|
64 | 72 | const pageData = await api.getPage(id)
|
65 | 73 | const end = new Date().getTime()
|
@@ -125,9 +133,13 @@ function filterPostBlocks(id, blockMap, slice) {
|
125 | 133 | }
|
126 | 134 |
|
127 | 135 | // 如果是文件,或嵌入式PDF,需要重新加密签名
|
128 |
| - if ((b?.value?.type === 'file' || b?.value?.type === 'pdf' || b?.value?.type === 'video' || b?.value?.type === 'audio') && |
129 |
| - b?.value?.properties?.source?.[0][0] && |
130 |
| - b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0 |
| 136 | + if ( |
| 137 | + (b?.value?.type === 'file' || |
| 138 | + b?.value?.type === 'pdf' || |
| 139 | + b?.value?.type === 'video' || |
| 140 | + b?.value?.type === 'audio') && |
| 141 | + b?.value?.properties?.source?.[0][0] && |
| 142 | + b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0 |
131 | 143 | ) {
|
132 | 144 | const oldUrl = b?.value?.properties?.source?.[0][0]
|
133 | 145 | const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
|
|
0 commit comments