mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
fix2
This commit is contained in:
@@ -84,63 +84,62 @@ function filterPostBlocks(id, blockMap, slice) {
|
||||
const blocksToProcess = Object.keys(clonePageBlock?.block || {})
|
||||
|
||||
// 循环遍历文档的每个block
|
||||
for (const i in clonePageBlock?.block) {
|
||||
for (let i = 0; i < blocksToProcess.length; i++) {
|
||||
const blockId = blocksToProcess[i]
|
||||
const b = clonePageBlock?.block[blockId]
|
||||
|
||||
if (slice && slice > 0 && count > slice) {
|
||||
delete clonePageBlock?.block[blockId]
|
||||
continue
|
||||
for (let i = 0; i < blocksToProcess.length; i++) {
|
||||
const blockId = blocksToProcess[i]
|
||||
const b = clonePageBlock?.block[blockId]
|
||||
|
||||
if (slice && slice > 0 && count > slice) {
|
||||
delete clonePageBlock?.block[blockId]
|
||||
continue
|
||||
}
|
||||
|
||||
if (b?.value?.id === id) {
|
||||
delete b?.value?.properties
|
||||
continue
|
||||
}
|
||||
|
||||
count++
|
||||
|
||||
if (b?.value?.type === 'sync_block' && b?.value?.children) {
|
||||
const childBlocks = b.value.children
|
||||
// Remove the sync block
|
||||
delete clonePageBlock.block[blockId]
|
||||
// Insert child blocks in place of the sync block
|
||||
childBlocks.forEach((childBlock, index) => {
|
||||
const newBlockId = `${blockId}_child_${index}`
|
||||
clonePageBlock.block[newBlockId] = childBlock
|
||||
blocksToProcess.splice(i + index + 1, 0, newBlockId)
|
||||
})
|
||||
// Adjust the loop counter to process the newly inserted blocks
|
||||
i--
|
||||
continue
|
||||
}
|
||||
|
||||
if (b?.value?.type === 'code') {
|
||||
if (b?.value?.properties?.language?.[0][0] === 'C++') {
|
||||
b.value.properties.language[0][0] = 'cpp'
|
||||
}
|
||||
|
||||
if (b?.value?.id === id) {
|
||||
delete b?.value?.properties
|
||||
continue
|
||||
if (b?.value?.properties?.language?.[0][0] === 'C#') {
|
||||
b.value.properties.language[0][0] = 'csharp'
|
||||
}
|
||||
|
||||
count++
|
||||
|
||||
if (b?.value?.type === 'sync_block' && b?.value?.children) {
|
||||
const childBlocks = b.value.children
|
||||
// Remove the sync block
|
||||
delete clonePageBlock.block[blockId]
|
||||
// Insert child blocks in place of the sync block
|
||||
childBlocks.forEach((childBlock, index) => {
|
||||
const newBlockId = `${blockId}_child_${index}`
|
||||
clonePageBlock.block[newBlockId] = childBlock
|
||||
blocksToProcess.splice(i + index + 1, 0, newBlockId)
|
||||
})
|
||||
// Adjust the loop counter to process the newly inserted blocks
|
||||
i--
|
||||
continue
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(b?.value?.type === 'file' ||
|
||||
b?.value?.type === 'pdf' ||
|
||||
b?.value?.type === 'video' ||
|
||||
b?.value?.type === 'audio') &&
|
||||
b?.value?.properties?.source?.[0][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
|
||||
if (b?.value?.properties?.language?.[0][0] === 'Assembly') {
|
||||
b.value.properties.language[0][0] = 'asm6502'
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(b?.value?.type === 'file' ||
|
||||
b?.value?.type === 'pdf' ||
|
||||
b?.value?.type === 'video' ||
|
||||
b?.value?.type === 'audio') &&
|
||||
b?.value?.properties?.source?.[0][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
|
||||
}
|
||||
}
|
||||
|
||||
// 去掉不用的字段
|
||||
if (id === BLOG.NOTION_PAGE_ID) {
|
||||
|
||||
Reference in New Issue
Block a user