From 87fd7d7fdd4bfc2577aa22da9926b605891abf49 Mon Sep 17 00:00:00 2001 From: TATSUNO Yasuhiro Date: Tue, 27 Nov 2018 18:27:10 +0900 Subject: [PATCH] feat: Add feature to specify href for logo explicitly (#645) Closes https://github.com/Rebilly/ReDoc/issues/627 --- docs/redoc-vendor-extensions.md | 1 + src/components/ApiLogo/ApiLogo.tsx | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/redoc-vendor-extensions.md b/docs/redoc-vendor-extensions.md index 062aec3c..c95a0461 100644 --- a/docs/redoc-vendor-extensions.md +++ b/docs/redoc-vendor-extensions.md @@ -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 diff --git a/src/components/ApiLogo/ApiLogo.tsx b/src/components/ApiLogo/ApiLogo.tsx index 290b862d..16d5258c 100644 --- a/src/components/ApiLogo/ApiLogo.tsx +++ b/src/components/ApiLogo/ApiLogo.tsx @@ -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'; @@ -24,7 +26,9 @@ export class ApiLogo extends React.Component<{ info: OpenAPIInfo }> { ); return ( - {info.contact && info.contact.url ? LinkWrap(info.contact.url)(logo) : logo}{' '} + { + logoHref ? LinkWrap(logoHref)(logo) : logo + } ); }