Added link from content to corresponding library items

This commit is contained in:
DrMint 2022-06-02 22:00:27 +02:00
parent 7446ad3f42
commit e1cd5424f7
3 changed files with 181 additions and 4 deletions

View File

@ -231,7 +231,7 @@ export function Markdawn(props: Immutable<Props>): JSX.Element {
component: (compProps: { children: React.ReactNode }) => ( component: (compProps: { children: React.ReactNode }) => (
<> <>
<HorizontalLine /> <HorizontalLine />
<div>{compProps.children}</div> <div className="grid gap-8">{compProps.children}</div>
</> </>
), ),
}, },

View File

@ -34,10 +34,11 @@ query getContentText($slug: String, $language_code: String) {
} }
library_item { library_item {
data { data {
id
attributes { attributes {
slug
title title
subtitle subtitle
slug
thumbnail { thumbnail {
data { data {
attributes { attributes {
@ -45,6 +46,112 @@ query getContentText($slug: String, $language_code: String) {
} }
} }
} }
release_date {
...datePicker
}
price {
...pricePicker
}
categories {
data {
id
attributes {
name
short
}
}
}
metadata {
__typename
... on ComponentMetadataBooks {
subtype {
data {
attributes {
slug
titles(
filters: {
language: { code: { eq: $language_code } }
}
) {
title
}
}
}
}
}
... on ComponentMetadataGame {
platforms {
data {
id
attributes {
short
}
}
}
}
... on ComponentMetadataVideo {
subtype {
data {
attributes {
slug
titles(
filters: {
language: { code: { eq: $language_code } }
}
) {
title
}
}
}
}
}
... on ComponentMetadataAudio {
subtype {
data {
attributes {
slug
titles(
filters: {
language: { code: { eq: $language_code } }
}
) {
title
}
}
}
}
}
... on ComponentMetadataGroup {
subtype {
data {
attributes {
slug
titles(
filters: {
language: { code: { eq: $language_code } }
}
) {
title
}
}
}
}
subitems_type {
data {
attributes {
slug
titles(
filters: {
language: { code: { eq: $language_code } }
}
) {
title
}
}
}
}
}
}
} }
} }
} }

View File

@ -1,6 +1,7 @@
import { AppLayout } from "components/AppLayout"; import { AppLayout } from "components/AppLayout";
import { Chip } from "components/Chip"; import { Chip } from "components/Chip";
import { HorizontalLine } from "components/HorizontalLine"; import { HorizontalLine } from "components/HorizontalLine";
import { PreviewCardCTAs } from "components/Library/PreviewCardCTAs";
import { Markdawn } from "components/Markdown/Markdawn"; import { Markdawn } from "components/Markdown/Markdawn";
import { TOC } from "components/Markdown/TOC"; import { TOC } from "components/Markdown/TOC";
import { import {
@ -9,7 +10,8 @@ import {
} from "components/PanelComponents/ReturnButton"; } from "components/PanelComponents/ReturnButton";
import { ContentPanel } from "components/Panels/ContentPanel"; import { ContentPanel } from "components/Panels/ContentPanel";
import { SubPanel } from "components/Panels/SubPanel"; import { SubPanel } from "components/Panels/SubPanel";
import { PreviewLine, TranslatedPreviewLine } from "components/PreviewLine"; import { PreviewCard } from "components/PreviewCard";
import { TranslatedPreviewLine } from "components/PreviewLine";
import { RecorderChip } from "components/RecorderChip"; import { RecorderChip } from "components/RecorderChip";
import { ThumbnailHeader } from "components/ThumbnailHeader"; import { ThumbnailHeader } from "components/ThumbnailHeader";
import { ToolTip } from "components/ToolTip"; import { ToolTip } from "components/ToolTip";
@ -19,8 +21,10 @@ import { getNextContent, getPreviousContent } from "helpers/contents";
import { import {
prettyinlineTitle, prettyinlineTitle,
prettyLanguage, prettyLanguage,
prettyItemSubType,
prettySlug, prettySlug,
} from "helpers/formatters"; } from "helpers/formatters";
import { isUntangibleGroupItem } from "helpers/libraryItem";
import { getStatusDescription } from "helpers/others"; import { getStatusDescription } from "helpers/others";
import { ContentWithTranslations, Immutable } from "helpers/types"; import { ContentWithTranslations, Immutable } from "helpers/types";
import { useMediaMobile } from "hooks/useMediaQuery"; import { useMediaMobile } from "hooks/useMediaQuery";
@ -38,7 +42,7 @@ interface Props extends AppStaticProps {
} }
export default function Content(props: Immutable<Props>): JSX.Element { export default function Content(props: Immutable<Props>): JSX.Element {
const { langui, content, languages } = props; const { langui, content, languages, currencies } = props;
const isMobile = useMediaMobile(); const isMobile = useMediaMobile();
const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({ const [selectedTranslation, LanguageSwitcher] = useSmartLanguage({
@ -184,6 +188,72 @@ export default function Content(props: Immutable<Props>): JSX.Element {
</div> </div>
)} )}
{content.ranged_contents?.data &&
content.ranged_contents.data.length > 0 && (
<>
<HorizontalLine />
<div>
{/* TODO: Add to langui */}
<p className="font-headers text-2xl">Source</p>
<div className="mt-6 grid gap-6 place-items-center text-left">
{content.ranged_contents.data.map((rangedContent) => {
const libraryItem =
rangedContent.attributes?.library_item?.data;
if (libraryItem?.attributes && libraryItem.id) {
return (
<div
key={libraryItem.attributes.slug}
className="mobile:w-[80%]"
>
<PreviewCard
href={`/library/${libraryItem.attributes.slug}`}
title={libraryItem.attributes.title}
subtitle={libraryItem.attributes.subtitle}
thumbnail={
libraryItem.attributes.thumbnail?.data?.attributes
}
thumbnailAspectRatio="21/29.7"
topChips={
libraryItem.attributes.metadata &&
libraryItem.attributes.metadata.length > 0 &&
libraryItem.attributes.metadata[0]
? [
prettyItemSubType(
libraryItem.attributes.metadata[0]
),
]
: []
}
bottomChips={libraryItem.attributes.categories?.data.map(
(category) => category.attributes?.short ?? ""
)}
metadata={{
currencies: currencies,
release_date: libraryItem.attributes.release_date,
price: libraryItem.attributes.price,
position: "Bottom",
}}
infoAppend={
<PreviewCardCTAs
id={libraryItem.id}
displayCTAs={
!isUntangibleGroupItem(
libraryItem.attributes.metadata?.[0]
)
}
/>
}
/>
</div>
);
}
return <></>;
})}
</div>
</div>
</>
)}
{selectedTranslation?.text_set?.text && ( {selectedTranslation?.text_set?.text && (
<> <>
<HorizontalLine /> <HorizontalLine />