Skip to content

Commit 4ca7d78

Browse files
authored
Merge branch 'tangly1024:main' into martini
2 parents 8028dab + 2c05ef0 commit 4ca7d78

File tree

7 files changed

+98
-54
lines changed

7 files changed

+98
-54
lines changed

lib/lang/en-US.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
COMMON: {
2323
THEME: 'Theme',
2424
ARTICLE_LIST: 'Article List',
25+
RECOMMEND_POSTS: 'Recommend Posts',
2526
MORE: 'More',
2627
NO_MORE: 'No More',
2728
LATEST_POSTS: 'Latest posts',

lib/lang/zh-CN.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default {
2222
COMMON: {
2323
THEME: 'Theme',
2424
ARTICLE_LIST: '文章列表',
25+
RECOMMEND_POSTS: '推荐文章',
2526
MORE: '更多',
2627
NO_MORE: '没有更多了',
2728
LATEST_POSTS: '最新发布',

lib/notion/getPostBlocks.js

+57-37
Original file line numberDiff line numberDiff line change
@@ -81,49 +81,69 @@ export async function getPageWithRetry(id, from, retryAttempts = 3) {
8181
function filterPostBlocks(id, blockMap, slice) {
8282
const clonePageBlock = deepClone(blockMap)
8383
let count = 0
84+
const blocksToProcess = Object.keys(clonePageBlock?.block || {})
8485

8586
// 循环遍历文档的每个block
86-
for (const i in clonePageBlock?.block) {
87-
const b = clonePageBlock?.block[i]
88-
if (slice && slice > 0 && count > slice) {
89-
delete clonePageBlock?.block[i]
90-
continue
87+
for (let i = 0; i < blocksToProcess.length; i++) {
88+
const blockId = blocksToProcess[i]
89+
const b = clonePageBlock?.block[blockId]
90+
91+
if (slice && slice > 0 && count > slice) {
92+
delete clonePageBlock?.block[blockId]
93+
continue
94+
}
95+
96+
// 当BlockId等于PageId时移除
97+
if (b?.value?.id === id) {
98+
// 此block含有敏感信息
99+
delete b?.value?.properties
100+
continue
101+
}
102+
103+
count++
104+
105+
if (b?.value?.type === 'sync_block' && b?.value?.children) {
106+
const childBlocks = b.value.children
107+
// 移除同步块
108+
delete clonePageBlock.block[blockId]
109+
// 用子块替代同步块
110+
childBlocks.forEach((childBlock, index) => {
111+
const newBlockId = `${blockId}_child_${index}`
112+
clonePageBlock.block[newBlockId] = childBlock
113+
blocksToProcess.splice(i + index + 1, 0, newBlockId)
114+
})
115+
// 重新处理新加入的子块
116+
i--
117+
continue
118+
}
119+
120+
// 处理 c++、c#、汇编等语言名字映射
121+
if (b?.value?.type === 'code') {
122+
if (b?.value?.properties?.language?.[0][0] === 'C++') {
123+
b.value.properties.language[0][0] = 'cpp'
91124
}
92-
// 当BlockId等于PageId时移除
93-
if (b?.value?.id === id) {
94-
// 此block含有敏感信息
95-
delete b?.value?.properties
96-
continue
125+
if (b?.value?.properties?.language?.[0][0] === 'C#') {
126+
b.value.properties.language[0][0] = 'csharp'
97127
}
98-
99-
count++
100-
// 处理 c++、c#、汇编等语言名字映射
101-
if (b?.value?.type === 'code') {
102-
if (b?.value?.properties?.language?.[0][0] === 'C++') {
103-
b.value.properties.language[0][0] = 'cpp'
104-
}
105-
if (b?.value?.properties?.language?.[0][0] === 'C#') {
106-
b.value.properties.language[0][0] = 'csharp'
107-
}
108-
if (b?.value?.properties?.language?.[0][0] === 'Assembly') {
109-
b.value.properties.language[0][0] = 'asm6502'
110-
}
111-
}
112-
113-
// 如果是文件,或嵌入式PDF,需要重新加密签名
114-
if (
115-
(b?.value?.type === 'file' ||
116-
b?.value?.type === 'pdf' ||
117-
b?.value?.type === 'video' ||
118-
b?.value?.type === 'audio') &&
119-
b?.value?.properties?.source?.[0][0] &&
120-
b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0
121-
) {
122-
const oldUrl = b?.value?.properties?.source?.[0][0]
123-
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
124-
b.value.properties.source[0][0] = newUrl
128+
if (b?.value?.properties?.language?.[0][0] === 'Assembly') {
129+
b.value.properties.language[0][0] = 'asm6502'
125130
}
126131
}
132+
133+
// 如果是文件,或嵌入式PDF,需要重新加密签名
134+
if (
135+
(b?.value?.type === 'file' ||
136+
b?.value?.type === 'pdf' ||
137+
b?.value?.type === 'video' ||
138+
b?.value?.type === 'audio') &&
139+
b?.value?.properties?.source?.[0][0] &&
140+
b?.value?.properties?.source?.[0][0].indexOf('amazonaws.com') > 0
141+
) {
142+
const oldUrl = b?.value?.properties?.source?.[0][0]
143+
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
144+
b.value.properties.source[0][0] = newUrl
145+
}
146+
}
127147

128148
// 去掉不用的字段
129149
if (id === BLOG.NOTION_PAGE_ID) {

themes/heo/components/BlogPostCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
3030
{/* 图片封面 */}
3131
{showPageCover && (
3232
<Link href={post?.href} passHref legacyBehavior>
33-
<div className='w-full md:w-5/12 2xl:w-full overflow-hidden'>
33+
<div className='w-full md:w-5/12 2xl:w-full overflow-hidden cursor-pointer select-none'>
3434
<LazyImage
3535
priority={index === 0}
3636
src={post?.pageCoverThumbnail}

themes/heo/components/Hero.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ function TodayCard({ cRef, siteInfo }) {
383383
}
384384
/>
385385
<div id='more' className='select-none'>
386-
{locale.COMMON.MORE}
386+
{locale.COMMON.RECOMMEND_POSTS}
387387
</div>
388388
</div>
389389
</div>
+27-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1+
import { useGlobal } from '@/lib/global'
12
import CategoryItem from './CategoryItem'
23

4+
/**
5+
* 分类
6+
* @param {*} param0
7+
* @returns
8+
*/
39
const CategoryGroup = ({ currentCategory, categoryOptions }) => {
10+
const { locale } = useGlobal()
411
if (!categoryOptions) {
512
return <></>
613
}
7-
return <div id='category-list' className='pt-4'>
8-
<div className='mb-2'><i className='mr-2 fas fa-th' />分类</div>
9-
<div className='flex flex-wrap'>
10-
{categoryOptions?.map(category => {
11-
const selected = currentCategory === category.name
12-
return <CategoryItem key={category.name} selected={selected} category={category.name} categoryCount={category.count} />
13-
})}
14+
return (
15+
<div id='category-list' className='pt-4'>
16+
<div className='mb-2'>
17+
<i className='mr-2 fas fa-th' />
18+
{locale.COMMON.CATEGORY}
19+
</div>
20+
<div className='flex flex-wrap'>
21+
{categoryOptions?.map(category => {
22+
const selected = currentCategory === category.name
23+
return (
24+
<CategoryItem
25+
key={category.name}
26+
selected={selected}
27+
category={category.name}
28+
categoryCount={category.count}
29+
/>
30+
)
31+
})}
32+
</div>
1433
</div>
15-
</div>
34+
)
1635
}
1736

1837
export default CategoryGroup

themes/medium/components/TagGroups.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useGlobal } from '@/lib/global'
12
import TagItemMini from './TagItemMini'
23

34
/**
@@ -8,17 +9,19 @@ import TagItemMini from './TagItemMini'
89
* @constructor
910
*/
1011
const TagGroups = ({ tagOptions, currentTag }) => {
12+
const { locale } = useGlobal()
1113
if (!tagOptions) return <></>
1214
return (
1315
<div id='tags-group' className='dark:border-gray-600 py-4'>
14-
<div className='mb-2'><i className='mr-2 fas fa-tag' />标签</div>
16+
<div className='mb-2'>
17+
<i className='mr-2 fas fa-tag' />
18+
{locale.COMMON.TAGS}
19+
</div>
1520
<div className='space-y-2'>
16-
{
17-
tagOptions?.map(tag => {
18-
const selected = tag.name === currentTag
19-
return <TagItemMini key={tag.name} tag={tag} selected={selected} />
20-
})
21-
}
21+
{tagOptions?.map(tag => {
22+
const selected = tag.name === currentTag
23+
return <TagItemMini key={tag.name} tag={tag} selected={selected} />
24+
})}
2225
</div>
2326
</div>
2427
)

0 commit comments

Comments
 (0)