@@ -8,7 +8,7 @@ const emojify = (text: string) => twemoji.parse(text, twOptions);
88
99const mono = readFileSync ( `${ __dirname } /../_fonts/Vera-Mono.woff2` ) . toString ( 'base64' ) ;
1010
11- function getCss ( theme : Theme , fontSize : string ) {
11+ function getCss ( theme : Theme , fontSize : string , thumbnail ?: string ) {
1212 let background = 'white' ;
1313 let foreground = 'black' ;
1414
@@ -31,6 +31,8 @@ function getCss(theme: Theme, fontSize: string) {
3131 break ;
3232 }
3333
34+ if ( thumbnail ) background = `linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, ${ background } 100%), url(${ thumbnail } );` ;
35+
3436 return `
3537 @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap');
3638
@@ -47,6 +49,9 @@ function getCss(theme: Theme, fontSize: string) {
4749
4850 body {
4951 background: ${ background } ;
52+ background-size: cover;
53+ background-position: center;
54+ background-repeat: no-repeat;
5055 height: 100vh;
5156 display: flex;
5257 flex-direction: column;
@@ -124,14 +129,14 @@ function getCss(theme: Theme, fontSize: string) {
124129}
125130
126131export function getHtml ( parsedReq : ParsedRequest ) {
127- const { title, description, theme, md, fontSize, images, widths, heights } = parsedReq ;
132+ const { title, description, thumbnail , theme, md, fontSize, images, widths, heights } = parsedReq ;
128133 return `<!DOCTYPE html>
129134<html>
130135 <meta charset="utf-8">
131136 <title>Generated Image</title>
132137 <meta name="viewport" content="width=device-width, initial-scale=1">
133138 <style>
134- ${ getCss ( theme , fontSize ) }
139+ ${ getCss ( theme , fontSize , thumbnail ) }
135140 </style>
136141 <body>
137142 <div class="container">
0 commit comments