Skip to content

Commit

Permalink
Merge pull request #2660 from NDLANO/use-url-and-context-from-node
Browse files Browse the repository at this point in the history
Use url from node rather than path
  • Loading branch information
gunnarvelle authored Jan 2, 2025
2 parents bc00895 + 62b599b commit 53a8f0a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/ndla-ui/src/Embed/RelatedContentEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ const RelatedContentEmbed = ({ embed, isOembed, subject, ndlaFrontendDomain }: P
if (embedData.articleId && data) {
const typeId = data.resource?.resourceTypes.find((rt) => contentTypeMapping[rt.id])?.id;
const type = typeId ? contentTypeMapping[typeId] : undefined;
const path =
data.resource?.paths.find((p) => p.split("/")[1] === subject?.replace("urn:", "")) ??
data.resource?.path ??
`/article/${embedData.articleId}`;
const context = data.resource?.contexts.find((c) => c.rootId === subject);
const url = context?.url ?? data.resource?.url ?? `/article/${embedData.articleId}`;
return (
<RelatedArticle
title={data.article.title?.title ?? ""}
introduction={data.article.metaDescription?.metaDescription ?? ""}
target={isOembed ? "_blank" : undefined}
to={`${ndlaFrontendDomain ?? ""}${path ?? ""}`}
to={`${ndlaFrontendDomain ?? ""}${url ?? ""}`}
type={type}
/>
);
Expand Down

0 comments on commit 53a8f0a

Please sign in to comment.