pass options to html2png
This commit is contained in:
parent
f6627672c9
commit
6876c5689e
2 changed files with 14 additions and 10 deletions
|
@ -116,8 +116,8 @@ const renderOptions = {
|
|||
]
|
||||
}
|
||||
|
||||
export default async function (html) {
|
||||
return html2png(html, css, renderOptions)
|
||||
export default async function (html, options = {}) {
|
||||
return html2png(html, css, { ...renderOptions, ...options })
|
||||
}
|
||||
|
||||
export async function renderHtml(html) {
|
||||
|
|
20
server.js
20
server.js
|
@ -81,9 +81,10 @@ app.get('/:owner/:repo', async function (req, res) {
|
|||
res.send(await renderHtml(html))
|
||||
return
|
||||
}
|
||||
res.type('png')
|
||||
const format = req.query.format == 'svg' ? 'svg' : 'png'
|
||||
res.type(format)
|
||||
res.set('Content-Disposition', 'inline')
|
||||
res.send(await render(html))
|
||||
res.send(await render(html, { format }))
|
||||
})
|
||||
|
||||
app.get('/:owner/:repo/commit/:hash', async function (req, res) {
|
||||
|
@ -127,9 +128,10 @@ app.get('/:owner/:repo/commit/:hash', async function (req, res) {
|
|||
res.send(await renderHtml(html))
|
||||
return
|
||||
}
|
||||
res.type('png')
|
||||
const format = req.query.format == 'svg' ? 'svg' : 'png'
|
||||
res.type(format)
|
||||
res.set('Content-Disposition', 'inline')
|
||||
res.send(await render(html))
|
||||
res.send(await render(html, { format }))
|
||||
})
|
||||
|
||||
app.get('/:owner/:repo/:type/:num', (req, res, next) => {
|
||||
|
@ -172,9 +174,10 @@ app.get('/:owner/:repo/issues/:num', async function (req, res) {
|
|||
res.send(await renderHtml(html))
|
||||
return
|
||||
}
|
||||
res.type('png')
|
||||
const format = req.query.format == 'svg' ? 'svg' : 'png'
|
||||
res.type(format)
|
||||
res.set('Content-Disposition', 'inline')
|
||||
res.send(await render(html))
|
||||
res.send(await render(html, { format }))
|
||||
})
|
||||
|
||||
app.get('/:owner/:repo/pulls/:num', async function (req, res) {
|
||||
|
@ -223,9 +226,10 @@ app.get('/:owner/:repo/pulls/:num', async function (req, res) {
|
|||
res.send(await renderHtml(html))
|
||||
return
|
||||
}
|
||||
res.type('png')
|
||||
const format = req.query.format == 'svg' ? 'svg' : 'png'
|
||||
res.type(format)
|
||||
res.set('Content-Disposition', 'inline')
|
||||
res.send(await render(html))
|
||||
res.send(await render(html, { format }))
|
||||
})
|
||||
|
||||
const [port, host] = [process.env.PORT ?? 9054, process.env.HOST ?? '127.0.0.1']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue