@@ -38,12 +38,14 @@ export async function* build(
38
38
yield `=== 开始编译 ${ book . name } ===` ;
39
39
let process = processPercentage ( 0.4 ) ;
40
40
/** 查询所有文档级block */
41
+ // TODO 需要更换成能够完全遍历一个笔记本的写法
41
42
const r : DB_block [ ] = await API . query_sql ( {
42
43
stmt : `
43
44
SELECT *
44
45
from blocks
45
46
WHERE box = '${ book . id } '
46
47
AND type = 'd'
48
+ limit 1500 OFFSET 0
47
49
` ,
48
50
} ) ;
49
51
yield `=== 查询文档级block完成 ===` ;
@@ -61,14 +63,19 @@ export async function* build(
61
63
const arr = Object . entries ( docTree ) ;
62
64
for ( let i = 0 ; i < arr . length ; i ++ ) {
63
65
const [ path , { sy } ] = arr [ i ] ;
64
- docHTML [ path + ".html" ] = await htmlTemplate (
65
- {
66
- title : sy . Properties ?. title || "" ,
67
- htmlContent : await renderHTML ( sy ) ,
68
- level : path . split ( "/" ) . length - 2 /** 最开头有一个 / 还有一个 data 目录所以减二 */ ,
69
- } ,
70
- config . cdn ,
71
- ) ;
66
+ try {
67
+ docHTML [ path + ".html" ] = await htmlTemplate (
68
+ {
69
+ title : sy . Properties ?. title || "" ,
70
+ htmlContent : await renderHTML ( sy ) ,
71
+ level : path . split ( "/" ) . length - 2 /** 最开头有一个 / 还有一个 data 目录所以减二 */ ,
72
+ } ,
73
+ config . cdn ,
74
+ ) ;
75
+ } catch ( error ) {
76
+ console . log ( path , "渲染失败" , error ) ;
77
+ }
78
+
72
79
process ( i / arr . length ) ;
73
80
yield `渲染: ${ path } ` ;
74
81
}
@@ -123,7 +130,10 @@ async function writeFileSystem(docTree: { [htmlPath: string]: string }, dir_ref:
123
130
await writeFile ( dir_ref , path , html ) ;
124
131
} ) ,
125
132
) ;
126
-
133
+ // for (const [path, html] of Object.entries(docTree)) {
134
+ // await writeFile(dir_ref, path, html);
135
+ // console.log("写出", path);
136
+ // }
127
137
async function writeFile ( dir_ref : any , name : string , data : string ) {
128
138
const pathArr = name . split ( "/" ) ;
129
139
/** 如果路径中的目录不存在则创建 */
0 commit comments