From 0e148f06cf339fa6cd754438ffc8f0b7980d6024 Mon Sep 17 00:00:00 2001
From: DrMint <29893320+DrMint@users.noreply.github.com>
Date: Wed, 15 May 2024 15:37:44 +0200
Subject: [PATCH] Now using attributes instead of tag groups
---
src/components/Attributes.astro | 87 +++++++++++
src/components/InlineAttributes.astro | 83 +++++++++++
src/components/InlineCredits.astro | 33 ++---
src/components/InlineMetadata.astro | 38 +++++
src/components/InlineTagGroups.astro | 64 --------
src/components/Lightbox.astro | 17 ++-
src/components/Metadata.astro | 8 +-
src/components/Previews/AudioPreview.astro | 10 +-
.../Previews/CollectiblePreview.astro | 4 +-
src/components/Previews/GenericPreview.astro | 10 +-
src/components/Previews/ImagePreview.astro | 4 +-
src/components/Previews/PagePreview.astro | 4 +-
src/components/Previews/VideoPreview.astro | 10 +-
src/components/TagGroups.astro | 50 -------
src/pages/[locale]/api/pages/partial.astro | 14 +-
src/pages/[locale]/audios/[id].astro | 10 +-
.../ContentsSection/ContentRow.astro | 6 +-
.../collectibles/[slug]/gallery/[index].astro | 8 +-
.../[locale]/collectibles/[slug]/index.astro | 25 ++--
src/pages/[locale]/images/[id].astro | 8 +-
src/pages/[locale]/videos/[id].astro | 10 +-
src/shared/payload/payload-sdk.ts | 139 +++++++-----------
src/utils/attributes.ts | 6 +
23 files changed, 356 insertions(+), 292 deletions(-)
create mode 100644 src/components/Attributes.astro
create mode 100644 src/components/InlineAttributes.astro
create mode 100644 src/components/InlineMetadata.astro
delete mode 100644 src/components/InlineTagGroups.astro
delete mode 100644 src/components/TagGroups.astro
create mode 100644 src/utils/attributes.ts
diff --git a/src/components/Attributes.astro b/src/components/Attributes.astro
new file mode 100644
index 0000000..4370eef
--- /dev/null
+++ b/src/components/Attributes.astro
@@ -0,0 +1,87 @@
+---
+import { AttributeTypes, type EndpointAttribute } from "src/shared/payload/payload-sdk";
+import Metadata from "./Metadata.astro";
+import { getI18n } from "src/i18n/i18n";
+import ErrorMessage from "./ErrorMessage.astro";
+import type { Attribute } from "src/utils/attributes";
+
+interface Props {
+ attributes: (EndpointAttribute | Attribute)[];
+}
+
+const { attributes } = Astro.props;
+const { getLocalizedMatch, getLocalizedUrl, formatNumber } = await getI18n(
+ Astro.locals.currentLocale
+);
+---
+
+{/* ------------------------------------------- HTML ------------------------------------------- */}
+
+
+ {
+ attributes.map((attribute) => {
+ if ("title" in attribute) {
+ return ;
+ }
+ const { icon, translations, value, type } = attribute;
+ const translation = getLocalizedMatch(translations);
+
+ switch (type) {
+ case AttributeTypes.Number:
+ return (
+
+ );
+
+ case AttributeTypes.Text:
+ return (
+
+ );
+
+ case AttributeTypes.Tags:
+ return (
+ ({
+ name: getLocalizedMatch(translations).name,
+ ...(page ? { href: getLocalizedUrl(`/pages/${page.slug}`) } : {}),
+ }))}
+ />
+ );
+
+ default:
+ return (
+
+ );
+ }
+ })
+ }
+
+
+
+{/* ------------------------------------------- CSS -------------------------------------------- */}
+
+
diff --git a/src/components/InlineAttributes.astro b/src/components/InlineAttributes.astro
new file mode 100644
index 0000000..d15af8d
--- /dev/null
+++ b/src/components/InlineAttributes.astro
@@ -0,0 +1,83 @@
+---
+import { AttributeTypes, type EndpointAttribute } from "src/shared/payload/payload-sdk";
+import InlineMetadata from "./InlineMetadata.astro";
+import { getI18n } from "src/i18n/i18n";
+import ErrorMessage from "./ErrorMessage.astro";
+import type { Attribute } from "src/utils/attributes";
+
+interface Props {
+ attributes: (EndpointAttribute | Attribute)[];
+}
+
+const { attributes } = Astro.props;
+const { getLocalizedMatch, getLocalizedUrl, formatNumber } = await getI18n(
+ Astro.locals.currentLocale
+);
+---
+
+{/* ------------------------------------------- HTML ------------------------------------------- */}
+
+
+ {
+ attributes.map((attribute) => {
+ if ("title" in attribute) {
+ return ;
+ }
+ const { icon, translations, value, type } = attribute;
+ const translation = getLocalizedMatch(translations);
+
+ switch (type) {
+ case AttributeTypes.Number:
+ return (
+
+ );
+
+ case AttributeTypes.Text:
+ return (
+
+ );
+
+ case AttributeTypes.Tags:
+ return (
+ ({
+ name: getLocalizedMatch(translations).name,
+ ...(page ? { href: getLocalizedUrl(`/pages/${page.slug}`) } : {}),
+ }))}
+ />
+ );
+
+ default:
+ return (
+
+ );
+ }
+ })
+ }
+
+
+
+{/* ------------------------------------------- CSS -------------------------------------------- */}
+
+
diff --git a/src/components/InlineCredits.astro b/src/components/InlineCredits.astro
index d99e122..0b28ce2 100644
--- a/src/components/InlineCredits.astro
+++ b/src/components/InlineCredits.astro
@@ -1,6 +1,7 @@
---
import type { EndpointCredit } from "src/shared/payload/payload-sdk";
import { getI18n } from "src/i18n/i18n";
+import InlineMetadata from "./InlineMetadata.astro";
interface Props {
credits: EndpointCredit[];
@@ -12,13 +13,14 @@ const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
{/* ------------------------------------------- HTML ------------------------------------------- */}
-
+
{
- credits.map(({ recorders, role: { translations } }) => (
-
-
{getLocalizedMatch(translations).name}
- {recorders.map(({ username }) => username).join(", ")}
-
+ credits.map(({ recorders, role: { icon, translations } }) => (
+
({ name: username }))}
+ />
))
}
@@ -26,21 +28,12 @@ const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
{/* ------------------------------------------- CSS -------------------------------------------- */}
diff --git a/src/components/InlineMetadata.astro b/src/components/InlineMetadata.astro
new file mode 100644
index 0000000..39a9717
--- /dev/null
+++ b/src/components/InlineMetadata.astro
@@ -0,0 +1,38 @@
+---
+import { Icon } from "astro-icon/components";
+import type { Attribute } from "src/utils/attributes";
+
+interface Props extends Attribute {}
+
+const { icon, title, values } = Astro.props;
+
+if (values.length === 0) return;
+---
+
+{/* ------------------------------------------- HTML ------------------------------------------- */}
+
+
+
+
{title}
+
{values.map(({ name }) => name).join(", ")}
+
+
+{/* ------------------------------------------- CSS -------------------------------------------- */}
+
+
diff --git a/src/components/InlineTagGroups.astro b/src/components/InlineTagGroups.astro
deleted file mode 100644
index 6fc8c29..0000000
--- a/src/components/InlineTagGroups.astro
+++ /dev/null
@@ -1,64 +0,0 @@
----
-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 | { title: string; icon: string; values: string[] })[];
-}
-
-const { tagGroups } = Astro.props;
-const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
-
-const groups = tagGroups.map((group) => {
- if ("title" in group) {
- return group;
- } else {
- return {
- title: getLocalizedMatch(group.translations).name,
- icon: group.icon,
- values: group.tags.map(({ translations }) => getLocalizedMatch(translations).name),
- };
- }
-});
----
-
-{/* ------------------------------------------- HTML ------------------------------------------- */}
-
-
-
-{/* ------------------------------------------- CSS -------------------------------------------- */}
-
-
diff --git a/src/components/Lightbox.astro b/src/components/Lightbox.astro
index 09e6a70..6b89488 100644
--- a/src/components/Lightbox.astro
+++ b/src/components/Lightbox.astro
@@ -5,12 +5,12 @@ import {
type PayloadImage,
type RichTextContent,
} from "src/shared/payload/payload-sdk";
-import TagGroups from "./TagGroups.astro";
import Credits from "./Credits.astro";
import DownloadButton from "./DownloadButton.astro";
import AppLayoutTitle from "./AppLayout/components/AppLayoutTitle.astro";
import type { ComponentProps } from "astro/types";
import AppLayoutDescription from "./AppLayout/components/AppLayoutDescription.astro";
+import Attributes from "./Attributes.astro";
interface Props {
previousImageHref?: string | undefined;
@@ -20,7 +20,8 @@ interface Props {
title: string;
subtitle?: string | undefined;
description?: RichTextContent | undefined;
- tagGroups?: ComponentProps
["tagGroups"] | undefined;
+ attributes?: ComponentProps["attributes"] | undefined;
+ metaAttributes?: ComponentProps["attributes"] | undefined;
credits?: EndpointCredit[] | undefined;
filename?: string | undefined;
}
@@ -29,8 +30,9 @@ const {
nextImageHref,
previousImageHref,
image: { url, width, height },
- tagGroups = [],
- credits,
+ attributes = [],
+ metaAttributes = [],
+ credits = [],
description,
pretitle,
title,
@@ -63,7 +65,7 @@ const smallTitle = !subtitle && !pretitle;
id="info"
class:list={{
complex:
- (tagGroups && tagGroups.length > 0) || (credits && credits.length > 0) || description,
+ attributes.length > 0 || metaAttributes.length > 0 || credits.length > 0 || description,
}}>
{
@@ -75,8 +77,9 @@ const smallTitle = !subtitle && !pretitle;
}
{description &&
}
- {tagGroups && tagGroups.length > 0 && }
- {credits && credits.length > 0 && }
+ {attributes.length > 0 && }
+ {credits.length > 0 && }
+ {metaAttributes.length > 0 && }
{filename && }
diff --git a/src/components/Metadata.astro b/src/components/Metadata.astro
index bce51d1..341308f 100644
--- a/src/components/Metadata.astro
+++ b/src/components/Metadata.astro
@@ -1,12 +1,8 @@
---
import { Icon } from "astro-icon/components";
+import type { Attribute } from "src/utils/attributes";
-interface Props {
- icon: string;
- title: string;
- values: { name: string; href?: string }[];
- withBorder?: boolean | undefined;
-}
+interface Props extends Attribute {}
const { icon, title, values, withBorder = true } = Astro.props;
diff --git a/src/components/Previews/AudioPreview.astro b/src/components/Previews/AudioPreview.astro
index 2735ef6..238c98e 100644
--- a/src/components/Previews/AudioPreview.astro
+++ b/src/components/Previews/AudioPreview.astro
@@ -12,7 +12,7 @@ const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n(
);
const {
- audio: { id, translations, tagGroups, filename, thumbnail, duration },
+ audio: { id, translations, attributes, filename, thumbnail, duration },
} = Astro.props;
const { pretitle, title, subtitle } =
@@ -20,12 +20,12 @@ const { pretitle, title, subtitle } =
? getLocalizedMatch(translations)
: { pretitle: undefined, title: filename, subtitle: undefined };
-const tagsAndAttributes = [
- ...tagGroups,
+const attributesWithMeta = [
+ ...attributes,
{
title: t("global.media.attributes.duration"),
icon: "material-symbols:hourglass-empty",
- values: [formatDuration(duration)],
+ values: [{ name: formatDuration(duration) }],
},
];
---
@@ -38,7 +38,7 @@ const tagsAndAttributes = [
subtitle={subtitle}
thumbnail={thumbnail}
href={getLocalizedUrl(`/audios/${id}`)}
- tagGroups={tagsAndAttributes}
+ attributes={attributesWithMeta}
icon="material-symbols:music-note"
iconHoverLabel={t("global.previewTypes.audio")}
smallTitle={title === filename}
diff --git a/src/components/Previews/CollectiblePreview.astro b/src/components/Previews/CollectiblePreview.astro
index 3421471..5c2e46d 100644
--- a/src/components/Previews/CollectiblePreview.astro
+++ b/src/components/Previews/CollectiblePreview.astro
@@ -10,7 +10,7 @@ interface Props {
const { getLocalizedMatch, getLocalizedUrl, t } = await getI18n(Astro.locals.currentLocale);
const {
- collectible: { slug, translations, thumbnail, tagGroups },
+ collectible: { slug, translations, thumbnail, attributes },
} = Astro.props;
const { title, pretitle, subtitle } = getLocalizedMatch(translations);
@@ -24,7 +24,7 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations);
subtitle={subtitle}
thumbnail={thumbnail}
href={getLocalizedUrl(`/collectibles/${slug}`)}
- tagGroups={tagGroups}
+ attributes={attributes}
icon="material-symbols:category"
iconHoverLabel={t("global.previewTypes.collectible")}
disableRoundedTop
diff --git a/src/components/Previews/GenericPreview.astro b/src/components/Previews/GenericPreview.astro
index 77d3d7d..1a598ab 100644
--- a/src/components/Previews/GenericPreview.astro
+++ b/src/components/Previews/GenericPreview.astro
@@ -4,7 +4,7 @@ import Card from "components/Card.astro";
import { Icon } from "astro-icon/components";
import type { ComponentProps } from "astro/types";
import { getI18n } from "src/i18n/i18n";
-import InlineTagGroups from "components/InlineTagGroups.astro";
+import InlineAttributes from "components/InlineAttributes.astro";
interface Props {
thumbnail?: PayloadImage | undefined;
@@ -12,7 +12,7 @@ interface Props {
title: string;
subtitle?: string | undefined;
href?: string | undefined;
- tagGroups?: ComponentProps["tagGroups"];
+ attributes?: ComponentProps["attributes"];
disableRoundedTop?: boolean;
smallTitle?: boolean;
icon?: string;
@@ -27,7 +27,7 @@ const {
pretitle,
subtitle,
href,
- tagGroups = [],
+ attributes = [],
smallTitle = false,
disableRoundedTop = false,
icon = "material-symbols:unknown-document",
@@ -63,11 +63,11 @@ const {
}
{
- tagGroups.length > 0 && (
+ attributes.length > 0 && (
<>
{subtitle &&
}
-
+
>
)
diff --git a/src/components/Previews/ImagePreview.astro b/src/components/Previews/ImagePreview.astro
index 566073a..d676684 100644
--- a/src/components/Previews/ImagePreview.astro
+++ b/src/components/Previews/ImagePreview.astro
@@ -11,7 +11,7 @@ const { getLocalizedMatch, getLocalizedUrl, t } = await getI18n(Astro.locals.cur
const {
image: thumbnail,
- image: { id, translations, tagGroups, filename },
+ image: { id, translations, attributes, filename },
} = Astro.props;
const { pretitle, title, subtitle } =
@@ -28,7 +28,7 @@ const { pretitle, title, subtitle } =
subtitle={subtitle}
thumbnail={thumbnail}
href={getLocalizedUrl(`/images/${id}`)}
- tagGroups={tagGroups}
+ attributes={attributes}
icon="material-symbols:imagesmode"
iconHoverLabel={t("global.previewTypes.image")}
smallTitle={title === filename}
diff --git a/src/components/Previews/PagePreview.astro b/src/components/Previews/PagePreview.astro
index 3664578..854d1a4 100644
--- a/src/components/Previews/PagePreview.astro
+++ b/src/components/Previews/PagePreview.astro
@@ -10,7 +10,7 @@ interface Props {
const { getLocalizedMatch, getLocalizedUrl, t } = await getI18n(Astro.locals.currentLocale);
const {
- page: { slug, translations, thumbnail, tagGroups },
+ page: { slug, translations, thumbnail, attributes },
} = Astro.props;
const { title, pretitle, subtitle } = getLocalizedMatch(translations);
@@ -24,7 +24,7 @@ const { title, pretitle, subtitle } = getLocalizedMatch(translations);
subtitle={subtitle}
thumbnail={thumbnail}
href={getLocalizedUrl(`/pages/${slug}`)}
- tagGroups={tagGroups}
+ attributes={attributes}
icon="material-symbols:docs"
iconHoverLabel={t("global.previewTypes.page")}
/>
diff --git a/src/components/Previews/VideoPreview.astro b/src/components/Previews/VideoPreview.astro
index 9eaf6a9..c499e6e 100644
--- a/src/components/Previews/VideoPreview.astro
+++ b/src/components/Previews/VideoPreview.astro
@@ -12,7 +12,7 @@ const { getLocalizedMatch, getLocalizedUrl, t, formatDuration } = await getI18n(
);
const {
- video: { id, translations, tagGroups, filename, thumbnail, duration },
+ video: { id, translations, attributes, filename, thumbnail, duration },
} = Astro.props;
const { pretitle, title, subtitle } =
@@ -20,12 +20,12 @@ const { pretitle, title, subtitle } =
? getLocalizedMatch(translations)
: { pretitle: undefined, title: filename, subtitle: undefined };
-const tagsAndAttributes = [
- ...tagGroups,
+const attributesWithMeta = [
+ ...attributes,
{
title: t("global.media.attributes.duration"),
icon: "material-symbols:hourglass-empty",
- values: [formatDuration(duration)],
+ values: [{ name: formatDuration(duration) }],
},
];
---
@@ -38,7 +38,7 @@ const tagsAndAttributes = [
subtitle={subtitle}
thumbnail={thumbnail}
href={getLocalizedUrl(`/videos/${id}`)}
- tagGroups={tagsAndAttributes}
+ attributes={attributesWithMeta}
icon="material-symbols:smart-display"
iconHoverLabel={t("global.previewTypes.video")}
smallTitle={title === filename}
diff --git a/src/components/TagGroups.astro b/src/components/TagGroups.astro
deleted file mode 100644
index 792a44f..0000000
--- a/src/components/TagGroups.astro
+++ /dev/null
@@ -1,50 +0,0 @@
----
-import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk";
-import { getI18n } from "src/i18n/i18n";
-import Metadata from "./Metadata.astro";
-import type { ComponentProps } from "astro/types";
-
-interface Props {
- tagGroups: (EndpointTagsGroup | ComponentProps)[];
-}
-
-const { tagGroups } = Astro.props;
-const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
-
-const groups = tagGroups.map((group) => {
- if ("title" in group) {
- return group;
- } else {
- return {
- title: getLocalizedMatch(group.translations).name,
- icon: group.icon,
- values: group.tags.map(({ translations, page }) => ({
- name: getLocalizedMatch(translations).name,
- ...(page ? { href: getLocalizedUrl(`/pages/${page.slug}`) } : {}),
- })),
- withBorder: true,
- };
- }
-});
----
-
-{/* ------------------------------------------- HTML ------------------------------------------- */}
-
-
- {groups.map((group) => )}
-
-
-
-{/* ------------------------------------------- CSS -------------------------------------------- */}
-
-
diff --git a/src/pages/[locale]/api/pages/partial.astro b/src/pages/[locale]/api/pages/partial.astro
index 6bd3f54..ef2bde3 100644
--- a/src/pages/[locale]/api/pages/partial.astro
+++ b/src/pages/[locale]/api/pages/partial.astro
@@ -3,13 +3,13 @@ import RichText from "components/RichText/RichText.astro";
import { payload, type EndpointPage } from "src/shared/payload/payload-sdk";
import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro";
import MasoTarget from "components/Maso/MasoTarget.astro";
-import TagGroups from "components/TagGroups.astro";
import TableOfContent from "components/TableOfContent/TableOfContent.astro";
import LanguageOverride from "components/LanguageOverride.astro";
import Credits from "components/Credits.astro";
import { getI18n } from "src/i18n/i18n";
import AsideLayout from "components/AppLayout/AsideLayout.astro";
import AppLayoutDescription from "components/AppLayout/components/AppLayoutDescription.astro";
+import Attributes from "components/Attributes.astro";
export const partial = true;
@@ -22,7 +22,7 @@ interface Props {
const reqUrl = new URL(Astro.request.url);
const lang = Astro.props.lang ?? reqUrl.searchParams.get("lang")!;
const slug = Astro.props.slug ?? reqUrl.searchParams.get("slug")!;
-const { translations, thumbnail, tagGroups, createdAt, updatedAt, updatedBy } =
+const { translations, thumbnail, createdAt, updatedAt, updatedBy, attributes } =
Astro.props.page ?? (await payload.getPage(slug));
const { getLocalizedUrl, t, formatDate } = await getI18n(Astro.locals.currentLocale);
@@ -31,7 +31,7 @@ const { getLocalizedMatch } = await getI18n(lang);
const { pretitle, title, subtitle, summary, content, credits, toc, language, sourceLanguage } =
getLocalizedMatch(translations);
-const attributes = [
+const metaAttributes = [
{
title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline",
@@ -47,7 +47,7 @@ const attributes = [
];
if (updatedBy) {
- attributes.push({
+ metaAttributes.push({
title: t("global.media.attributes.updatedBy"),
icon: "material-symbols:person-edit-outline",
values: [{ name: updatedBy.username }],
@@ -82,9 +82,9 @@ if (updatedBy) {
{summary && }
{
- tagGroups.length > 0 && (
+ attributes.length > 0 && (
)
}
@@ -108,7 +108,7 @@ if (updatedBy) {
{credits.length > 0 && }
- {attributes.length > 0 && }
+ {metaAttributes.length > 0 && }
{toc.length > 0 && }
diff --git a/src/pages/[locale]/audios/[id].astro b/src/pages/[locale]/audios/[id].astro
index 48e969f..e79ef3a 100644
--- a/src/pages/[locale]/audios/[id].astro
+++ b/src/pages/[locale]/audios/[id].astro
@@ -1,11 +1,11 @@
---
import AppLayout from "components/AppLayout/AppLayout.astro";
import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro";
+import Attributes from "components/Attributes.astro";
import AudioPlayer from "components/AudioPlayer.astro";
import Credits from "components/Credits.astro";
import DownloadButton from "components/DownloadButton.astro";
import RichText from "components/RichText/RichText.astro";
-import TagGroups from "components/TagGroups.astro";
import { getI18n } from "src/i18n/i18n";
import { payload } from "src/shared/payload/payload-sdk";
import { formatInlineTitle, formatRichTextToString } from "src/utils/format";
@@ -22,7 +22,7 @@ const { getLocalizedMatch, t, formatFilesize, formatDate } = await getI18n(
);
const {
translations,
- tagGroups,
+ attributes,
filename,
url,
credits,
@@ -36,7 +36,7 @@ const { pretitle, title, subtitle, description } = getLocalizedMatch(translation
const smallTitle = !subtitle && !pretitle;
-const attributes = [
+const metaAttributes = [
...(filename && title !== filename
? [
{
@@ -89,9 +89,9 @@ const attributes = [
)
}
{description && }
- {tagGroups.length > 0 && }
+ {attributes.length > 0 && }
{credits.length > 0 && }
- {attributes.length > 0 && }
+ {metaAttributes.length > 0 && }
diff --git a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro
index beb17a7..fef0c48 100644
--- a/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro
+++ b/src/pages/[locale]/collectibles/[slug]/_components/ContentsSection/ContentRow.astro
@@ -4,10 +4,10 @@ import RichText from "components/RichText/RichText.astro";
import { getI18n } from "src/i18n/i18n";
import { Collections, type EndpointCollectible } from "src/shared/payload/payload-sdk";
import { formatInlineTitle } from "src/utils/format";
-import InlineTagGroups from "../../../../../../components/InlineTagGroups.astro";
import Card from "components/Card.astro";
import AudioPlayer from "components/AudioPlayer.astro";
import VideoPlayer from "components/VideoPlayer.astro";
+import InlineAttributes from "components/InlineAttributes.astro";
interface Props {
content: EndpointCollectible["contents"][number];
@@ -99,9 +99,9 @@ const href = (() => {
(content.relationTo === Collections.Pages ||
content.relationTo === Collections.Audios ||
content.relationTo === Collections.Videos) &&
- content.value.tagGroups.length > 0 && (
+ content.value.attributes.length > 0 && (
-
+
)
}
diff --git a/src/pages/[locale]/collectibles/[slug]/gallery/[index].astro b/src/pages/[locale]/collectibles/[slug]/gallery/[index].astro
index 4e4c5d2..bdda80f 100644
--- a/src/pages/[locale]/collectibles/[slug]/gallery/[index].astro
+++ b/src/pages/[locale]/collectibles/[slug]/gallery/[index].astro
@@ -18,15 +18,14 @@ if (galleryImage instanceof Response) {
}
const { parentPages, previousIndex, nextIndex, image } = galleryImage;
-const { filename, translations, createdAt, updatedAt, credits, tagGroups } = image;
+const { filename, translations, createdAt, updatedAt, credits, attributes } = image;
const { pretitle, title, subtitle, description } =
translations.length > 0
? getLocalizedMatch(translations)
: { pretitle: undefined, title: filename, subtitle: undefined, description: undefined };
-const tagsAndAttributes = [
- ...tagGroups,
+const metaAttributes = [
...(filename && title !== filename
? [
{
@@ -74,7 +73,8 @@ const tagsAndAttributes = [
: undefined}
description={description}
filename={filename}
- tagGroups={tagsAndAttributes}
+ attributes={attributes}
+ metaAttributes={metaAttributes}
credits={credits}
/>
diff --git a/src/pages/[locale]/collectibles/[slug]/index.astro b/src/pages/[locale]/collectibles/[slug]/index.astro
index b750be1..6884c94 100644
--- a/src/pages/[locale]/collectibles/[slug]/index.astro
+++ b/src/pages/[locale]/collectibles/[slug]/index.astro
@@ -1,7 +1,6 @@
---
import AppLayout from "components/AppLayout/AppLayout.astro";
import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro";
-import TagGroups from "components/TagGroups.astro";
import { getI18n } from "src/i18n/i18n";
import { CollectibleNature, payload } from "src/shared/payload/payload-sdk";
import { fetchOr404 } from "src/utils/responses";
@@ -16,6 +15,7 @@ import { formatInlineTitle, formatLocale, formatRichTextToString } from "src/uti
import AsideLayout from "components/AppLayout/AsideLayout.astro";
import AppLayoutDescription from "components/AppLayout/components/AppLayoutDescription.astro";
import { convert } from "src/utils/currencies";
+import Attributes from "components/Attributes.astro";
const { slug } = Astro.params;
const { getLocalizedMatch, getLocalizedUrl, t, formatDate, formatPrice } = await getI18n(
@@ -41,7 +41,7 @@ const {
scans,
subitems,
parentPages,
- tagGroups,
+ attributes,
contents,
createdAt,
updatedAt,
@@ -53,7 +53,7 @@ const {
const translation = getLocalizedMatch(translations);
const { pretitle, title, subtitle, description } = translation;
-const attributes = [
+const metaAttributes = [
{
title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline",
@@ -69,7 +69,7 @@ const attributes = [
];
if (updatedBy) {
- attributes.push({
+ metaAttributes.push({
title: t("global.media.attributes.updatedBy"),
icon: "material-symbols:person-edit-outline",
values: [{ name: updatedBy.username }],
@@ -77,8 +77,7 @@ if (updatedBy) {
});
}
-const tagGroupWithAttributes = [
- ...tagGroups,
+const additionalAttributes = [
{
title: t("collectibles.nature"),
icon: "material-symbols:leaf-spark-outline",
@@ -96,7 +95,7 @@ const tagGroupWithAttributes = [
];
if (releaseDate) {
- tagGroupWithAttributes.push({
+ additionalAttributes.push({
title: t("collectibles.releaseDate"),
icon: "material-symbols:calendar-month-outline",
values: [{ name: formatDate(new Date(releaseDate)) }],
@@ -105,7 +104,7 @@ if (releaseDate) {
}
if (languages.length > 0) {
- tagGroupWithAttributes.push({
+ additionalAttributes.push({
title: t("collectibles.languages"),
icon: "material-symbols:translate",
values: languages.map((lang) => ({ name: formatLocale(lang) })),
@@ -127,7 +126,7 @@ if (price) {
priceText += ` (${formatPrice(convertedPrice)})`;
}
- tagGroupWithAttributes.push({
+ additionalAttributes.push({
title: t("collectibles.price"),
icon: "material-symbols:sell-outline",
values: [{ name: priceText }],
@@ -194,9 +193,9 @@ if (price) {
{
- attributes.length > 0 && (
+ metaAttributes.length > 0 && (
)
}
@@ -206,7 +205,7 @@ if (price) {
{description && }
diff --git a/src/pages/[locale]/images/[id].astro b/src/pages/[locale]/images/[id].astro
index bd08d15..e29fc22 100644
--- a/src/pages/[locale]/images/[id].astro
+++ b/src/pages/[locale]/images/[id].astro
@@ -13,15 +13,14 @@ if (image instanceof Response) {
}
const { getLocalizedMatch, formatDate, t } = await getI18n(Astro.locals.currentLocale);
-const { filename, translations, tagGroups, credits, createdAt, updatedAt } = image;
+const { filename, translations, attributes, credits, createdAt, updatedAt } = image;
const { pretitle, title, subtitle, description } =
translations.length > 0
? getLocalizedMatch(translations)
: { pretitle: undefined, title: filename, subtitle: undefined, description: undefined };
-const tagsAndAttributes = [
- ...tagGroups,
+const metaAttributes = [
...(filename && title !== filename
? [
{
@@ -62,7 +61,8 @@ const tagsAndAttributes = [
subtitle={subtitle}
description={description}
filename={filename}
- tagGroups={tagsAndAttributes}
+ attributes={attributes}
+ metaAttributes={metaAttributes}
credits={credits}
/>
diff --git a/src/pages/[locale]/videos/[id].astro b/src/pages/[locale]/videos/[id].astro
index 129ea67..81619d2 100644
--- a/src/pages/[locale]/videos/[id].astro
+++ b/src/pages/[locale]/videos/[id].astro
@@ -1,10 +1,10 @@
---
import AppLayout from "components/AppLayout/AppLayout.astro";
import AppLayoutTitle from "components/AppLayout/components/AppLayoutTitle.astro";
+import Attributes from "components/Attributes.astro";
import Credits from "components/Credits.astro";
import DownloadButton from "components/DownloadButton.astro";
import RichText from "components/RichText/RichText.astro";
-import TagGroups from "components/TagGroups.astro";
import VideoPlayer from "components/VideoPlayer.astro";
import { getI18n } from "src/i18n/i18n";
import { payload } from "src/shared/payload/payload-sdk";
@@ -22,7 +22,7 @@ const { getLocalizedMatch, t, formatFilesize, formatDate } = await getI18n(
);
const {
translations,
- tagGroups,
+ attributes,
filename,
url,
credits,
@@ -35,7 +35,7 @@ const {
const { pretitle, title, subtitle, description } = getLocalizedMatch(translations);
const smallTitle = !subtitle && !pretitle;
-const attributes = [
+const metaAttributes = [
...(filename && title !== filename
? [
{
@@ -88,9 +88,9 @@ const attributes = [
)
}
{description && }
- {tagGroups.length > 0 && }
+ {attributes.length > 0 && }
{credits.length > 0 && }
- {attributes.length > 0 && }
+ {metaAttributes.length > 0 && }
diff --git a/src/shared/payload/payload-sdk.ts b/src/shared/payload/payload-sdk.ts
index 68b27cb..5e4124c 100644
--- a/src/shared/payload/payload-sdk.ts
+++ b/src/shared/payload/payload-sdk.ts
@@ -32,7 +32,6 @@ export interface Config {
"videos-channels": VideosChannel;
scans: Scan;
tags: Tag;
- "tags-groups": TagsGroup;
attributes: Attribute;
"credits-roles": CreditsRole;
recorders: Recorder;
@@ -56,8 +55,8 @@ export interface Page {
slug: string;
thumbnail?: string | Image | null;
backgroundImage?: string | Image | null;
- attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
tags?: (string | Tag)[] | null;
+ attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
translations: {
language: string | Language;
sourceLanguage: string | Language;
@@ -135,6 +134,7 @@ export interface Image {
}[]
| null;
tags?: (string | Tag)[] | null;
+ attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
credits?: Credits;
updatedAt: string;
createdAt: string;
@@ -177,26 +177,8 @@ export interface Language {
*/
export interface Tag {
id: string;
- name?: string | null;
slug: string;
- translations: {
- language: string | Language;
- name: string;
- id?: string | null;
- }[];
- group: string | TagsGroup;
page?: (string | null) | Page;
- updatedAt: string;
- createdAt: string;
-}
-/**
- * This interface was referenced by `Config`'s JSON-Schema
- * via the `definition` "tags-groups".
- */
-export interface TagsGroup {
- id: string;
- slug: string;
- icon?: string | null;
translations: {
language: string | Language;
name: string;
@@ -205,42 +187,6 @@ export interface TagsGroup {
updatedAt: string;
createdAt: string;
}
-/**
- * This interface was referenced by `Config`'s JSON-Schema
- * via the `definition` "credits-roles".
- */
-export interface CreditsRole {
- id: string;
- slug: string;
- icon?: string | null;
- translations: {
- language: string | Language;
- name: string;
- id?: string | null;
- }[];
- updatedAt: string;
- createdAt: string;
-}
-/**
- * This interface was referenced by `Config`'s JSON-Schema
- * via the `definition` "recorders".
- */
-export interface Recorder {
- id: string;
- username: string;
- avatar?: string | Image | null;
- languages?: (string | Language)[] | null;
- role?: ("Admin" | "Recorder" | "Api")[] | null;
- anonymize: boolean;
- email: string;
- resetPasswordToken?: string | null;
- resetPasswordExpiration?: string | null;
- salt?: string | null;
- hash?: string | null;
- loginAttempts?: number | null;
- lockUntil?: string | null;
- password?: string | null;
-}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "TagsBlock".
@@ -291,6 +237,42 @@ export interface TextBlock {
blockName?: string | null;
blockType: "textBlock";
}
+/**
+ * This interface was referenced by `Config`'s JSON-Schema
+ * via the `definition` "credits-roles".
+ */
+export interface CreditsRole {
+ id: string;
+ slug: string;
+ icon?: string | null;
+ translations: {
+ language: string | Language;
+ name: string;
+ id?: string | null;
+ }[];
+ updatedAt: string;
+ createdAt: string;
+}
+/**
+ * This interface was referenced by `Config`'s JSON-Schema
+ * via the `definition` "recorders".
+ */
+export interface Recorder {
+ id: string;
+ username: string;
+ avatar?: string | Image | null;
+ languages?: (string | Language)[] | null;
+ role?: ("Admin" | "Recorder" | "Api")[] | null;
+ anonymize: boolean;
+ email: string;
+ resetPasswordToken?: string | null;
+ resetPasswordExpiration?: string | null;
+ salt?: string | null;
+ hash?: string | null;
+ loginAttempts?: number | null;
+ lockUntil?: string | null;
+ password?: string | null;
+}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "folders".
@@ -371,6 +353,7 @@ export interface Collectible {
nature: "Physical" | "Digital";
languages?: (string | Language)[] | null;
tags?: (string | Tag)[] | null;
+ attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
translations: {
language: string | Language;
pretitle?: string | null;
@@ -635,6 +618,7 @@ export interface Audio {
id?: string | null;
}[];
tags?: (string | Tag)[] | null;
+ attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
credits?: Credits;
updatedAt: string;
createdAt: string;
@@ -710,6 +694,7 @@ export interface Video {
id?: string | null;
}[];
tags?: (string | Tag)[] | null;
+ attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
credits?: Credits;
platformEnabled?: boolean | null;
platform?: {
@@ -1042,27 +1027,26 @@ export interface SectionBlock {
export enum Collections {
+ Attributes = "attributes",
Audios = "audios",
ChronologyEvents = "chronology-events",
+ Collectibles = "collectibles",
+ CreditsRole = "credits-roles",
Currencies = "currencies",
+ Folders = "folders",
+ GenericContents = "generic-contents",
+ Images = "images",
Languages = "languages",
+ MediaThumbnails = "media-thumbnails",
Pages = "pages",
Recorders = "recorders",
- Folders = "folders",
- Tags = "tags",
- TagsGroups = "tags-groups",
- Images = "images",
- Wordings = "wordings",
- Collectibles = "collectibles",
- GenericContents = "generic-contents",
- WebsiteConfig = "website-config",
- Videos = "videos",
- VideosSubtitles = "videos-subtitles",
- VideosChannels = "videos-channels",
- MediaThumbnails = "media-thumbnails",
Scans = "scans",
- CreditsRole = "credits-roles",
- Attributes = "attributes",
+ Tags = "tags",
+ Videos = "videos",
+ VideosChannels = "videos-channels",
+ VideosSubtitles = "videos-subtitles",
+ Wordings = "wordings",
+ WebsiteConfig = "website-config",
}
export enum CollectionGroups {
@@ -1507,16 +1491,6 @@ export type EndpointTag = {
}[];
};
-export type EndpointTagsGroup = {
- slug: string;
- icon: string;
- translations: {
- language: string;
- name: string;
- }[];
- tags: EndpointTag[];
-};
-
export type EndpointGenericAttribute = {
slug: string;
icon: string;
@@ -1562,7 +1536,6 @@ export type EndpointCredit = {
export type EndpointPage = {
slug: string;
thumbnail?: EndpointImage;
- tagGroups: EndpointTagsGroup[];
attributes: EndpointAttribute[];
backgroundImage?: EndpointImage;
translations: {
@@ -1592,7 +1565,7 @@ export type EndpointCollectible = {
subtitle?: string;
description?: RichTextContent;
}[];
- tagGroups: EndpointTagsGroup[];
+ attributes: EndpointAttribute[];
releaseDate?: string;
languages: string[];
backgroundImage?: EndpointImage;
@@ -1816,7 +1789,7 @@ export type EndpointMedia = {
filesize: number;
updatedAt: string;
createdAt: string;
- tagGroups: EndpointTagsGroup[];
+ attributes: EndpointAttribute[];
translations: {
language: string;
pretitle?: string;
diff --git a/src/utils/attributes.ts b/src/utils/attributes.ts
new file mode 100644
index 0000000..4bb906a
--- /dev/null
+++ b/src/utils/attributes.ts
@@ -0,0 +1,6 @@
+export type Attribute = {
+ icon: string;
+ title: string;
+ values: { name: string; href?: string }[];
+ withBorder?: boolean | undefined;
+};