Skip to content

Commit

Permalink
feat: Add feature to specify href for logo explicitly (#645)
Browse files Browse the repository at this point in the history
Closes #627
  • Loading branch information
TATSUNO Yasuhiro authored and RomanHotsiy committed Nov 27, 2018
1 parent 5e6f6ff commit 87fd7d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/redoc-vendor-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ The information about API logo
| url | string | The URL pointing to the spec logo. MUST be in the format of a URL. It SHOULD be an absolute URL so your API definition is usable from any location
| backgroundColor | string | background color to be used. MUST be RGB color in [hexadecimal format] (https://en.wikipedia.org/wiki/Web_colors#Hex_triplet)
| altText | string | Text to use for alt tag on the logo. Defaults to 'logo' if nothing is provided.
| href | string | The URL pointing to the contact page. Default to 'info.contact.url' field of the OAS.


###### x-logo example
Expand Down
6 changes: 5 additions & 1 deletion src/components/ApiLogo/ApiLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
if (!logoInfo || !logoInfo.url) {
return null;
}

const logoHref = logoInfo.href || (info.contact && info.contact.url);

// Use the english word logo if no alt text is provided
const altText = logoInfo.altText ? logoInfo.altText : 'logo';
Expand All @@ -24,7 +26,9 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
);
return (
<LogoWrap>
{info.contact && info.contact.url ? LinkWrap(info.contact.url)(logo) : logo}{' '}
{
logoHref ? LinkWrap(logoHref)(logo) : logo
}
</LogoWrap>
);
}
Expand Down

0 comments on commit 87fd7d7

Please sign in to comment.