mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-11-04 09:47:31 +03:00 
			
		
		
		
	added support for specifying target in x-logo href
This commit is contained in:
		
							parent
							
								
									3ae251b7e4
								
							
						
					
					
						commit
						b2538b281f
					
				| 
						 | 
				
			
			@ -121,11 +121,12 @@ The information about API logo
 | 
			
		|||
 | 
			
		||||
#### Fixed fields
 | 
			
		||||
| Field Name      | Type    | Description                                                                                                                                        |
 | 
			
		||||
| :-------------- | :------: | :---------- |
 | 
			
		||||
| :-------------- | :------: |:---------------------------------------------------------------------------------------------------------------------------------------------------|
 | 
			
		||||
| 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.                                                              |
 | 
			
		||||
| hrefTarget        | string   | The target of the generated anchor tag.                                                                                               |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#### x-logo example
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    const logoHref = logoInfo.href || (info.contact && info.contact.url);
 | 
			
		||||
    const logoHrefTarget = logoInfo.hrefTarget;
 | 
			
		||||
 | 
			
		||||
    // Use the english word logo if no alt text is provided
 | 
			
		||||
    const altText = logoInfo.altText ? logoInfo.altText : 'logo';
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +21,7 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> {
 | 
			
		|||
    const logo = <LogoImgEl src={logoInfo.url} alt={altText} />;
 | 
			
		||||
    return (
 | 
			
		||||
      <LogoWrap style={{ backgroundColor: logoInfo.backgroundColor }}>
 | 
			
		||||
        {logoHref ? LinkWrap(logoHref)(logo) : logo}
 | 
			
		||||
        {logoHref ? LinkWrap({ url: logoHref, target: logoHrefTarget })(logo) : logo}
 | 
			
		||||
      </LogoWrap>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,5 +17,12 @@ const Link = styled.a`
 | 
			
		|||
  display: inline-block;
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line react/display-name
 | 
			
		||||
export const LinkWrap = url => Component => <Link href={url}>{Component}</Link>;
 | 
			
		||||
export const LinkWrap =
 | 
			
		||||
  ({ url, target }) =>
 | 
			
		||||
  // eslint-disable-next-line react/display-name
 | 
			
		||||
  Component =>
 | 
			
		||||
    (
 | 
			
		||||
      <Link href={url} target={target}>
 | 
			
		||||
        {Component}
 | 
			
		||||
      </Link>
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user