diff --git a/src/components/Previews/CollectiblePreview.astro b/src/components/Previews/CollectiblePreview.astro index 35d4022..bb892fa 100644 --- a/src/components/Previews/CollectiblePreview.astro +++ b/src/components/Previews/CollectiblePreview.astro @@ -1,4 +1,5 @@ --- +import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; import type { EndpointCollectiblePreview } from "src/shared/payload/payload-sdk"; @@ -9,7 +10,7 @@ interface Props { const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale); const { - collectible: { slug, translations, thumbnail }, + collectible: { slug, translations, thumbnail, tagGroups }, } = Astro.props; const { title, pretitle, subtitle } = getLocalizedMatch(translations); @@ -17,57 +18,12 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations); {/* ------------------------------------------- HTML ------------------------------------------- */} - - { - thumbnail && ( - - ) - } - -

- {pretitle && {pretitle} } - {title}  - {subtitle && {subtitle}} -

-
- -{/* ------------------------------------------- CSS -------------------------------------------- */} - - + diff --git a/src/components/Previews/GenericPreview.astro b/src/components/Previews/GenericPreview.astro new file mode 100644 index 0000000..15865b3 --- /dev/null +++ b/src/components/Previews/GenericPreview.astro @@ -0,0 +1,132 @@ +--- +import type { EndpointTagsGroup, PayloadImage } from "src/shared/payload/payload-sdk"; +import ConditionalWrapper from "../ConditionalWrapper.astro"; +import Link from "../Link.astro"; +import InlineTagGroups from "pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro"; + +interface Props { + thumbnail?: PayloadImage | undefined; + pretitle?: string | undefined; + title: string; + subtitle?: string | undefined; + href?: string | undefined; + tagGroups?: EndpointTagsGroup[]; + disableRoundedTop?: boolean; +} + +const { + thumbnail, + title, + pretitle, + subtitle, + href, + tagGroups = [], + disableRoundedTop = false, +} = Astro.props; +--- + + +
+ { + thumbnail && ( + + ) + } + +
+

+ {pretitle && {pretitle} } + {title}  + {subtitle && {subtitle}} +

+ + { + tagGroups.length > 0 && ( + <> + {subtitle &&
} +
+ +
+ + ) + } +
+
+
+ + diff --git a/src/components/Previews/PagePreview.astro b/src/components/Previews/PagePreview.astro index 929a8c2..0bc8518 100644 --- a/src/components/Previews/PagePreview.astro +++ b/src/components/Previews/PagePreview.astro @@ -1,4 +1,5 @@ --- +import GenericPreview from "components/Previews/GenericPreview.astro"; import { getI18n } from "src/i18n/i18n"; import type { EndpointPagePreview } from "src/shared/payload/payload-sdk"; @@ -9,7 +10,7 @@ interface Props { const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale); const { - page: { slug, translations, thumbnail }, + page: { slug, translations, thumbnail, tagGroups }, } = Astro.props; const { title, pretitle, subtitle } = getLocalizedMatch(translations); @@ -17,57 +18,11 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations); {/* ------------------------------------------- HTML ------------------------------------------- */} - - { - thumbnail && ( - - ) - } - -

- {pretitle && {pretitle} } - {title}  - {subtitle && {subtitle}} -

-
- -{/* ------------------------------------------- CSS -------------------------------------------- */} - - + diff --git a/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro b/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro new file mode 100644 index 0000000..edb73d1 --- /dev/null +++ b/src/pages/[locale]/collectibles/_components/ContentsSection/InlineTagGroups.astro @@ -0,0 +1,52 @@ +--- +import { Icon } from "astro-icon/components"; +import { getI18n } from "src/i18n/i18n"; +import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk"; + +interface Props { + tagGroups: EndpointTagsGroup[]; +} + +const { tagGroups } = Astro.props; +const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale); +--- + +{/* ------------------------------------------- HTML ------------------------------------------- */} + +
+ { + tagGroups.map(({ icon, translations, tags }) => ( +
+ +

{getLocalizedMatch(translations).name}

+
{tags.map(({ translations }) => getLocalizedMatch(translations).name).join(", ")}
+
+ )) + } +
+ +{/* ------------------------------------------- CSS -------------------------------------------- */} + +