mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 16:46:34 +03:00
feat: Add feature to specify href for logo explicitly (#645)
Closes https://github.com/Rebilly/ReDoc/issues/627
This commit is contained in:
parent
5e6f6fff03
commit
87fd7d7fdd
|
@ -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
|
| 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)
|
| 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.
|
| 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
|
###### x-logo example
|
||||||
|
|
|
@ -12,6 +12,8 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logoHref = logoInfo.href || (info.contact && info.contact.url);
|
||||||
|
|
||||||
// Use the english word logo if no alt text is provided
|
// Use the english word logo if no alt text is provided
|
||||||
const altText = logoInfo.altText ? logoInfo.altText : 'logo';
|
const altText = logoInfo.altText ? logoInfo.altText : 'logo';
|
||||||
|
|
||||||
|
@ -24,7 +26,9 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<LogoWrap>
|
<LogoWrap>
|
||||||
{info.contact && info.contact.url ? LinkWrap(info.contact.url)(logo) : logo}{' '}
|
{
|
||||||
|
logoHref ? LinkWrap(logoHref)(logo) : logo
|
||||||
|
}
|
||||||
</LogoWrap>
|
</LogoWrap>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user