1
1
const { readingTimeCalc, imgToDataURL } = require ( './utils' ) ;
2
2
3
3
const ArticleCard = async ( data , colors ) => {
4
-
5
4
const thumbnailBase64 = await imgToDataURL ( data . thumbnail ) ;
6
5
const articleDate = new Date ( data . pubDate ) ;
7
6
const readingTime = readingTimeCalc ( data . content ) ;
8
- var re = / [ 0 - 9 A - F a - f ] { 6 } / g; //hex code format
9
- var hexBg = null
10
- var hexText = null
11
- console . log ( colors )
7
+ const re = / [ 0 - 9 A - F a - f ] { 6 } / g; //hex code format
8
+ let hexBg = null ;
9
+ let hexText = null ;
12
10
if ( re . test ( colors . bg ) ) { //converted to hex format
13
11
hexBg = `#${ colors . bg } `
14
12
}
@@ -18,7 +16,7 @@ const ArticleCard = async (data, colors) => {
18
16
19
17
return `
20
18
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="390px" height="100px" version="1.2" baseProfile="tiny" style="margin: 10px">
21
- <rect width="100%" height="100%" fill="${ hexBg ? hexBg : colors . bg } " style="padding:10px;"/>
19
+ <rect width="100%" height="100%" fill="${ hexBg ? hexBg : colors . bg } " style="padding:10px;"/>
22
20
<g fill="none" stroke="black" stroke-width="1" fill-rule="evenodd" stroke-linecap="square" stroke-linejoin="bevel">
23
21
24
22
<g fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2" transform="matrix(1,0,0,1,0,0)">
@@ -28,9 +26,7 @@ const ArticleCard = async (data, colors) => {
28
26
</g>
29
27
30
28
<g fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2" transform="matrix(1,0,0,1,0,0)">
31
- <pattern patternUnits="userSpaceOnUse" x="0" y="0" width="100%" height="100%">
32
- <image x="0" y="0" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="${ thumbnailBase64 } "/>
33
- </pattern>
29
+ <image x="0" y="0" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="${ thumbnailBase64 } "/>
34
30
</g>
35
31
36
32
<g fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="square" stroke-linejoin="bevel" transform="matrix(1,0,0,1,0,0)">
0 commit comments