Skip to content

Commit

Permalink
Added copyright info for metaImage
Browse files Browse the repository at this point in the history
  • Loading branch information
MaPoKen committed Oct 7, 2024
1 parent 78fa9fc commit 4ae4928
Show file tree
Hide file tree
Showing 5 changed files with 269 additions and 61 deletions.
5 changes: 5 additions & 0 deletions src/containers/SubjectPage/components/SubjectTopic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
GQLTopic_SubjectFragment,
GQLTopic_TopicFragment,
} from "../../../graphqlTypes";
import { copyrightInfoFragment } from "../../../queries";
import { toTopic, useUrnIds } from "../../../routeHelpers";
import { getTopicPath } from "../../../util/getTopicPath";
import { htmlTitle } from "../../../util/titleHelper";
Expand Down Expand Up @@ -217,6 +218,9 @@ export const topicFragments = {
metaImage {
url
alt
copyright {
...CopyrightInfo
}
}
transformedContent(transformArgs: $transformArgs) {
visualElementEmbed {
Expand All @@ -229,6 +233,7 @@ export const topicFragments = {
}
${MultidisciplinaryArticleList.fragments.topic}
${Resources.fragments.topic}
${copyrightInfoFragment}
`,
resourceType: gql`
fragment Topic_ResourceTypeDefinition on ResourceTypeDefinition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@
*/

import { Image } from "@ndla/primitives";
import { styled } from "@ndla/styled-system/jsx";
import { EmbedMetaData } from "@ndla/types-embed";
import { ImageEmbed } from "@ndla/ui";
import { EmbedByline, ImageEmbed } from "@ndla/ui";
import { GQLArticle } from "../../../graphqlTypes";

interface Props {
embed: EmbedMetaData;
metaImage: GQLArticle["metaImage"];
metaImage?: GQLArticle["metaImage"];
}

const StyledFigure = styled("figure", {
base: {
display: "flex",
flexDirection: "column",
alignItems: "center",
},
});

const TopicVisualElementContent = ({ embed, metaImage }: Props) => {
if (embed.resource === "image") {
return <ImageEmbed embed={{ ...embed, embedData: { ...embed.embedData, caption: "" } }} />;
} else if (!metaImage) {
return null;
} else {
return (
<figure>
<StyledFigure>
<Image src={metaImage?.url ?? ""} alt={metaImage?.alt ?? ""} />
</figure>
{metaImage.copyright ? (
<EmbedByline
type="image"
copyright={{ ...metaImage.copyright, processed: !!metaImage.copyright.processed }}
hideDescription
/>
) : null}
</StyledFigure>
);
}
};
Expand Down
Loading

0 comments on commit 4ae4928

Please sign in to comment.