Skip to content

Commit

Permalink
Merge pull request #346 from nstapelbroek/set-apidocs-title
Browse files Browse the repository at this point in the history
feat: use config.Info.Title as the page title in the API docs
  • Loading branch information
danielgtaylor committed Apr 1, 2024
2 parents 10e15d1 + 4c998f3 commit ee299ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,17 @@ func NewAPI(config Config, a Adapter) API {
openAPIPath = path.Join(prefix, openAPIPath)
}
ctx.SetHeader("Content-Type", "text/html")
title := "Elements in HTML"
if config.Info != nil && config.Info.Title != "" {
title = config.Info.Title + " Reference"
}
ctx.BodyWriter().Write([]byte(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Elements in HTML</title>
<title>` + title + `</title>
<!-- Embed elements Elements via Web Component -->
<link href="https://unpkg.com/@stoplight/[email protected]/styles.min.css" rel="stylesheet" />
<script src="https://unpkg.com/@stoplight/[email protected]/web-components.min.js"
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/features/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ router.Get("/docs", func(w http.ResponseWriter, r *http.Request) {
<meta charset="utf-8" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Elements in HTML</title>
<title>Docs Example reference</title>
<!-- Embed elements Elements via Web Component -->
<link href="https://unpkg.com/@stoplight/[email protected]/styles.min.css" rel="stylesheet" />
<script src="https://unpkg.com/@stoplight/[email protected]/web-components.min.js"
Expand Down

0 comments on commit ee299ec

Please sign in to comment.