Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #627: Add feature to specify href for logo explicitly #645

Merged
merged 2 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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