feat: customize html title for swagger-ui (#845)
* feat: customize html title for swagger-ui * chore: add changesetpull/848/head
parent
c063c66a55
commit
934b3932c1
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@hono/swagger-ui': minor
|
||||
---
|
||||
|
||||
customize html title for swagger-ui
|
|
@ -35,6 +35,7 @@ type OriginalSwaggerUIOptions = {
|
|||
* ```
|
||||
*/
|
||||
manuallySwaggerUIHtml?: (asset: AssetURLs) => string
|
||||
title?: string
|
||||
}
|
||||
|
||||
type SwaggerUIOptions = OriginalSwaggerUIOptions & DistSwaggerUIOptions
|
||||
|
@ -68,13 +69,14 @@ const SwaggerUI = (options: SwaggerUIOptions) => {
|
|||
const middleware =
|
||||
<E extends Env>(options: SwaggerUIOptions): MiddlewareHandler<E> =>
|
||||
async (c) => {
|
||||
const title = options?.title ?? "SwaggerUI"
|
||||
return c.html(/* html */ `
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="description" content="SwaggerUI" />
|
||||
<title>SwaggerUI</title>
|
||||
<title>${title}</title>
|
||||
</head>
|
||||
<body>
|
||||
${SwaggerUI(options)}
|
||||
|
|
Loading…
Reference in New Issue