Skip to content

Commit

Permalink
Merge pull request tangly1024#1511 from tangly1024/fix/file-upload
Browse files Browse the repository at this point in the history
Fix/file upload
  • Loading branch information
tangly1024 committed Sep 7, 2023
2 parents fd859e6 + 232d2aa commit e3a2728
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=4.0.14
NEXT_PUBLIC_VERSION=4.0.15
2 changes: 1 addition & 1 deletion components/WWAds.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export default function WWAds({ orientation = 'vertical', sticky = false, classN
}

return (
<div className={`wwads-cn ${orientation === 'vertical' ? 'wwads-vertical' : 'wwads-horizontal'} ${sticky ? 'wwads-sticky' : ''} z-30 ${className || ''}`} data-id={BLOG.AD_WWADS_ID}></div>
<div className={`wwads-cn ${orientation === 'vertical' ? 'wwads-vertical' : 'wwads-horizontal'} ${sticky ? 'wwads-sticky' : ''} z-10 ${className || ''}`} data-id={BLOG.AD_WWADS_ID}></div>
)
}
9 changes: 9 additions & 0 deletions lib/notion/getPostBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) {

/**
* 获取到的blockMap删除不需要的字段
* 并且对于页面内容进行特殊处理,比如文件url格式化
* @param {*} id 页面ID
* @param {*} pageBlock 页面元素
* @param {*} slice 截取数量
Expand All @@ -72,6 +73,7 @@ function filterPostBlocks(id, pageBlock, slice) {
const clonePageBlock = deepClone(pageBlock)
let count = 0

// 循环遍历文档的每个block
for (const i in clonePageBlock?.block) {
const b = clonePageBlock?.block[i]
if (slice && slice > 0 && count > slice) {
Expand Down Expand Up @@ -99,6 +101,13 @@ function filterPostBlocks(id, pageBlock, slice) {
}
}

// 如果是文件,或嵌入式PDF,需要重新加密签名
if ((b?.value?.type === 'file' || b?.value?.type === 'pdf') && b?.value?.properties?.source?.[0][0]) {
const oldUrl = b?.value?.properties?.source?.[0][0]
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
b.value.properties.source[0][0] = newUrl
}

delete b?.role
delete b?.value?.version
delete b?.value?.created_by_table
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion-next",
"version": "4.0.14",
"version": "4.0.15",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
Expand Down

0 comments on commit e3a2728

Please sign in to comment.