@@ -6,6 +6,7 @@ import fs from 'fs'
6
6
import path from 'path'
7
7
import genHtml from './genHtml'
8
8
import Koa from 'koa'
9
+ import tdkConfig from '../../config/tdk'
9
10
10
11
const ejsPath = path . join ( __dirname , '../../templates/server.ejs' )
11
12
const store = getStore ( )
@@ -21,14 +22,10 @@ export default async (ctx: Koa.Context, next: Koa.Next): Promise<null> => {
21
22
styles . forEach ( ( style : any ) => cssObj . add ( style . _getContent ( ) ) )
22
23
const { html, fetchResult } = await genHtml ( path , insertCss , store )
23
24
const { page } = fetchResult || { }
24
- let tdk = {
25
- title : 'noov.js' ,
26
- keywords : '默认关键词' ,
27
- description : '默认描述'
28
- }
25
+ let tdk = tdkConfig [ path as keyof typeof tdkConfig ]
29
26
// 添加TDK
30
- if ( page && page . tdk ) {
31
- tdk = page . tdk
27
+ if ( Object . keys ( page ) . length ) {
28
+ tdk = page
32
29
}
33
30
const styles : string [ ] = [ ]
34
31
Array . from ( cssObj ) . forEach ( ( item : any ) => {
@@ -43,7 +40,6 @@ export default async (ctx: Koa.Context, next: Koa.Next): Promise<null> => {
43
40
js : [ ] ,
44
41
css : [ ]
45
42
}
46
- console . log ( 'assets===>' , assets )
47
43
if ( typeof ( assets as Promise < IAssets > ) . then === 'function' ) {
48
44
const res = await ( assets as Promise < IAssets > )
49
45
assetsMap = res as typeof assetsMap
@@ -53,7 +49,6 @@ export default async (ctx: Koa.Context, next: Koa.Next): Promise<null> => {
53
49
return assetsMap
54
50
}
55
51
const assetsMap = await getAssetsMap ( )
56
- console . log ( 'assetsMap' , assetsMap )
57
52
const template = fs . readFileSync ( ejsPath , { encoding : 'utf-8' } )
58
53
const result = ejs . render ( template , {
59
54
tdk,
@@ -66,8 +61,7 @@ export default async (ctx: Koa.Context, next: Koa.Next): Promise<null> => {
66
61
showInitData : Object . keys ( fetchResult || { } ) . length > 0 ,
67
62
showState : Object . keys ( store . getState ( ) || { } ) . length > 0
68
63
} )
69
- console . log ( 'result' , result )
70
64
ctx . body = result
71
- await next ( )
65
+ // await next()
72
66
return null
73
67
}
0 commit comments