Created
June 7, 2025 07:53
-
-
Save wmz1024/356c3644f89aa46a75942fde2a9acebe to your computer and use it in GitHub Desktop.
Nobelium Attachment Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const blockMap1 = await getPostBlocks(post.id) | |
| const clonePageBlock = blockMap1 | |
| let count = 0 | |
| const blocksToProcess = Object.keys(clonePageBlock?.block || {}) | |
| for (let i = 0; i < blocksToProcess.length; i++) { | |
| const blockId = blocksToProcess[i] | |
| const b = clonePageBlock?.block[blockId] | |
| count++ | |
| // 处理 c++、c#、汇编等语言名字映射 | |
| if (b?.value?.type === 'code') { | |
| if (b?.value?.properties?.language?.[0][0] === 'C++') { | |
| b.value.properties.language[0][0] = 'cpp' | |
| } | |
| if (b?.value?.properties?.language?.[0][0] === 'C#') { | |
| b.value.properties.language[0][0] = 'csharp' | |
| } | |
| if (b?.value?.properties?.language?.[0][0] === 'Assembly') { | |
| b.value.properties.language[0][0] = 'asm6502' | |
| } | |
| } | |
| // 如果是文件,或嵌入式PDF,需要重新加密签名 | |
| if ( | |
| ['file', 'pdf', 'video', 'audio'].includes(b?.value?.type) && | |
| b?.value?.properties?.source?.[0][0] && | |
| (b?.value?.properties?.source?.[0][0].indexOf('attachment') === 0 || | |
| b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 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 | |
| } | |
| } | |
| const blockMap = clonePageBlock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment