@@ -31,17 +31,17 @@ export const convertToUSA = (date) => {
31
31
}
32
32
33
33
/**
34
- * @param {HeadMetaData } metaData
34
+ * @param {import("../util/type.js").MetaData } metaData
35
35
* @param {string } [content]
36
36
*/
37
37
export const replaceHead = async ( metaData , content ) => {
38
38
const res = content ??
39
39
await Deno . readTextFile ( new URL ( 'head.html' , import . meta. url ) )
40
- const { keywords, description , title, version } = metaData
40
+ const { keywords, summary , title, version } = metaData
41
41
42
42
return res
43
43
. replace ( '<!-- keywords -->' , keywords )
44
- . replace ( '<!-- description -->' , description )
44
+ . replace ( '<!-- description -->' , summary )
45
45
. replace ( '<!-- title -->' , title )
46
46
. replace ( '<!-- base.css -->' , `/public/css/base.${ version } .css` )
47
47
. replace ( '<!-- index.css -->' , `/public/css/index.${ version } .css` )
@@ -66,29 +66,34 @@ export const replaceBody = (header, footer, version, src) => {
66
66
}
67
67
68
68
/**
69
- * @param {import("./type.js").GeneratePageOptions }
69
+ * @param {string[] } tags
70
+ * @param {string } basePath
70
71
*/
72
+ export const generateTags = ( /**@type {string[] } */ tags , basePath = 'tags' ) =>
73
+ tags . reduce (
74
+ ( acc , tag ) =>
75
+ acc +
76
+ `<a class="tag" href="/./${ basePath } /${ tag } /"><i class="fa-solid fa-tag"></i> ${ tag } </a>` ,
77
+ '' ,
78
+ )
79
+
80
+ /**@param {import("./type.js").GeneratePageOptions }*/
71
81
export async function generatePage (
72
82
{ group, basePath, dist, header, footer, version, author } ,
73
83
) {
74
84
const url = new URL ( `./${ basePath } /index.html` , dist )
75
85
const keys = Object . keys ( group )
76
86
const head = await replaceHead ( {
77
87
keywords : keys . join ( ', ' ) ,
78
- description : `${ author } ~ ${ basePath } ` ,
88
+ summary : `${ author } ~ ${ basePath } ` ,
79
89
title : `${ author } ~ ${ basePath } ` ,
80
90
version,
81
91
} )
82
92
83
93
// a tags
84
94
const body = templateArticle ( {
85
95
title : basePath ,
86
- content : keys . reduce (
87
- ( acc , tag ) =>
88
- acc +
89
- `<a class="tag" href="/./${ basePath } /${ tag } /"><i class="fa-solid fa-tag"></i> ${ tag } </a>` ,
90
- '' ,
91
- ) ,
96
+ content : generateTags ( keys , basePath ) ,
92
97
} )
93
98
const article = `${ head } ${ header } ${ body } ${ footer } `
94
99
if ( ! await exists ( url ) ) await ensureFile ( url )
@@ -98,7 +103,7 @@ export async function generatePage(
98
103
const itemUrl = new URL ( `./${ basePath } /${ key } /index.html` , dist )
99
104
const itemHead = await replaceHead ( {
100
105
keywords : [ ...new Set ( items . flatMap ( ( item ) => item . tags ) ) ] ,
101
- description : `${ author } ~ ${ key } ` ,
106
+ summary : `${ author } ~ ${ key } ` ,
102
107
title : `${ author } ~ ${ key } ` ,
103
108
version,
104
109
} )
0 commit comments