Skip to content

Commit

Permalink
feat: allow relative urls for resources
Browse files Browse the repository at this point in the history
jerelmiller committed Aug 1, 2020
1 parent 6eb5fd3 commit beba6cb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/PageLayout/RelatedContent.js
Original file line number Diff line number Diff line change
@@ -100,15 +100,22 @@ const RelatedContent = ({ page }) => {
`}
>
{resources.map((resource) => {
const tag = Object.keys(SITE_TAGS).find((tag) =>
resource.url.startsWith(SITE_TAGS[tag])
);
const tag = resource.url.startsWith('/')
? 'developer'
: Object.keys(SITE_TAGS).find((tag) =>
resource.url.startsWith(SITE_TAGS[tag])
);

const isDeveloperSite = tag === 'developer';

const url = new URL(resource.url);
const LinkElement = isDeveloperSite ? Link : ExternalLink;
const props = isDeveloperSite
? { to: url.pathname }
? {
to: resource.url.replace(
'https://developer.newrelic.com',
''
),
}
: { href: resource.url };

return (

0 comments on commit beba6cb

Please sign in to comment.