Support for tag page

This commit is contained in:
DrMint 2024-05-15 11:52:42 +02:00
parent bf7d2b907f
commit 600a2374e1
11 changed files with 187 additions and 68 deletions

View File

@ -19,7 +19,7 @@ const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
<Metadata <Metadata
icon={icon} icon={icon}
title={getLocalizedMatch(translations).name} title={getLocalizedMatch(translations).name}
values={recorders.map(({ username }) => username)} values={recorders.map(({ username }) => ({ name: username }))}
/> />
)) ))
} }

View File

@ -4,7 +4,7 @@ import { Icon } from "astro-icon/components";
interface Props { interface Props {
icon: string; icon: string;
title: string; title: string;
values: string[]; values: { name: string; href?: string }[];
withBorder?: boolean | undefined; withBorder?: boolean | undefined;
} }
@ -21,7 +21,17 @@ if (values.length === 0) return;
<p>{title}</p> <p>{title}</p>
</div> </div>
<div id="values" class:list={{ "with-border": withBorder }}> <div id="values" class:list={{ "with-border": withBorder }}>
{values.map((value) => <div>{value}</div>)} {
values.map(({ name, href }) =>
href ? (
<a class="pressable high-contrast-text" href={href}>
{name}
</a>
) : (
<div>{name}</div>
)
)
}
</div> </div>
</div> </div>
@ -56,13 +66,16 @@ if (values.length === 0) return;
gap: 6px; gap: 6px;
&.with-border { &.with-border {
& > div { & > * {
border: 1px solid var(--color-base-1000);
border-radius: 9999px; border-radius: 9999px;
padding-bottom: 0.25em; padding-bottom: 0.25em;
padding-top: 0.15em; padding-top: 0.15em;
padding-inline: 0.6em; padding-inline: 0.6em;
backdrop-filter: blur(10upx); backdrop-filter: blur(10px);
}
& > div {
border: 1px solid var(--color-base-1000);
} }
} }
} }

View File

@ -2,16 +2,14 @@
import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk"; import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk";
import { getI18n } from "src/i18n/i18n"; import { getI18n } from "src/i18n/i18n";
import Metadata from "./Metadata.astro"; import Metadata from "./Metadata.astro";
import type { ComponentProps } from "astro/types";
interface Props { interface Props {
tagGroups: ( tagGroups: (EndpointTagsGroup | ComponentProps<typeof Metadata>)[];
| EndpointTagsGroup
| { title: string; icon: string; values: string[]; withBorder?: boolean }
)[];
} }
const { tagGroups } = Astro.props; const { tagGroups } = Astro.props;
const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale); const { getLocalizedMatch, getLocalizedUrl } = await getI18n(Astro.locals.currentLocale);
const groups = tagGroups.map((group) => { const groups = tagGroups.map((group) => {
if ("title" in group) { if ("title" in group) {
@ -20,7 +18,11 @@ const groups = tagGroups.map((group) => {
return { return {
title: getLocalizedMatch(group.translations).name, title: getLocalizedMatch(group.translations).name,
icon: group.icon, icon: group.icon,
values: group.tags.map(({ translations }) => getLocalizedMatch(translations).name), values: group.tags.map(({ translations, page }) => ({
name: getLocalizedMatch(translations).name,
...(page ? { href: getLocalizedUrl(`/pages/${page.slug}`) } : {}),
})),
withBorder: true,
}; };
} }
}); });
@ -29,11 +31,7 @@ const groups = tagGroups.map((group) => {
{/* ------------------------------------------- HTML ------------------------------------------- */} {/* ------------------------------------------- HTML ------------------------------------------- */}
<div> <div>
{ {groups.map((group) => <Metadata {...group} />)}
groups.map(({ icon, title, values, withBorder }) => (
<Metadata icon={icon} title={title} values={values} withBorder={withBorder} />
))
}
<slot /> <slot />
</div> </div>

View File

@ -69,6 +69,8 @@ export type WordingKey =
| "collectibles.bookFormat.binding.hardcover" | "collectibles.bookFormat.binding.hardcover"
| "collectibles.bookFormat.binding.readingDirection.leftToRight" | "collectibles.bookFormat.binding.readingDirection.leftToRight"
| "collectibles.bookFormat.binding.readingDirection.rightToLeft" | "collectibles.bookFormat.binding.readingDirection.rightToLeft"
| "collectibles.gallery"
| "collectibles.scans"
| "collectibles.imageCount" | "collectibles.imageCount"
| "header.topbar.settings.tooltip" | "header.topbar.settings.tooltip"
| "collectibles.contents" | "collectibles.contents"
@ -87,29 +89,29 @@ export type WordingKey =
| "pages.tableOfContent.break" | "pages.tableOfContent.break"
| "global.languageOverride.availableLanguages" | "global.languageOverride.availableLanguages"
| "timeline.title" | "timeline.title"
| "timeline.description" | "timeline.eras.drakengard3"
| "timeline.eras.cataclysm"
| "timeline.eras.drakengard" | "timeline.eras.drakengard"
| "timeline.eras.drakengard2" | "timeline.eras.drakengard2"
| "timeline.eras.drakengard3"
| "timeline.eras.nier" | "timeline.eras.nier"
| "timeline.eras.nierAutomata" | "timeline.eras.nierAutomata"
| "timeline.jumpTo" | "timeline.eras.cataclysm"
| "timeline.notes.content" | "timeline.description"
| "timeline.notes.title" | "timeline.notes.title"
| "timeline.notes.content"
| "timeline.priorCataclysmNote.title" | "timeline.priorCataclysmNote.title"
| "timeline.priorCataclysmNote.content" | "timeline.priorCataclysmNote.content"
| "timeline.jumpTo"
| "timeline.year.during" | "timeline.year.during"
| "timeline.eventFooter.sources"
| "timeline.eventFooter.languages" | "timeline.eventFooter.languages"
| "timeline.eventFooter.sources"
| "timeline.eventFooter.note" | "timeline.eventFooter.note"
| "global.sources.typeLabel.url"
| "global.sources.typeLabel.page"
| "global.sources.typeLabel.collectible" | "global.sources.typeLabel.collectible"
| "global.sources.typeLabel.collectible.range.custom" | "global.sources.typeLabel.folder"
| "global.sources.typeLabel.collectible.range.page" | "global.sources.typeLabel.collectible.range.page"
| "global.sources.typeLabel.collectible.range.timestamp" | "global.sources.typeLabel.collectible.range.timestamp"
| "global.sources.typeLabel.folder" | "global.sources.typeLabel.collectible.range.custom"
| "global.sources.typeLabel.page"
| "global.sources.typeLabel.url"
| "global.openMediaPage" | "global.openMediaPage"
| "global.downloadButton" | "global.downloadButton"
| "global.previewTypes.video" | "global.previewTypes.video"
@ -119,8 +121,6 @@ export type WordingKey =
| "global.previewTypes.collectible" | "global.previewTypes.collectible"
| "global.previewTypes.unknown" | "global.previewTypes.unknown"
| "collectibles.scans.title" | "collectibles.scans.title"
| "collectibles.gallery.title"
| "collectibles.gallery.subtitle"
| "collectibles.scans.subtitle" | "collectibles.scans.subtitle"
| "collectibles.scans.shortIndex.flapFront" | "collectibles.scans.shortIndex.flapFront"
| "collectibles.scans.shortIndex.front" | "collectibles.scans.shortIndex.front"
@ -134,9 +134,11 @@ export type WordingKey =
| "collectibles.scans.obi" | "collectibles.scans.obi"
| "collectibles.scans.obiInside" | "collectibles.scans.obiInside"
| "collectibles.scans.pages" | "collectibles.scans.pages"
| "collectibles.gallery.title"
| "collectibles.gallery.subtitle"
| "global.sources.typeLabel.scans"
| "collectibles.scans.dustjacket.description" | "collectibles.scans.dustjacket.description"
| "collectibles.scans.obi.description" | "collectibles.scans.obi.description"
| "global.sources.typeLabel.scans"
| "global.sources.typeLabel.gallery" | "global.sources.typeLabel.gallery"
| "global.media.attributes.filename" | "global.media.attributes.filename"
| "global.media.attributes.duration" | "global.media.attributes.duration"
@ -145,4 +147,6 @@ export type WordingKey =
| "global.media.attributes.updatedAt" | "global.media.attributes.updatedAt"
| "global.media.attributes.updatedBy" | "global.media.attributes.updatedBy"
| "collectibles.nature" | "collectibles.nature"
| "collectibles.languages"; | "collectibles.languages"
| "collectibles.nature.physical"
| "collectibles.nature.digital";

View File

@ -35,13 +35,13 @@ const attributes = [
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];
@ -50,7 +50,7 @@ if (updatedBy) {
attributes.push({ attributes.push({
title: t("global.media.attributes.updatedBy"), title: t("global.media.attributes.updatedBy"),
icon: "material-symbols:person-edit-outline", icon: "material-symbols:person-edit-outline",
values: [updatedBy?.username], values: [{ name: updatedBy.username }],
withBorder: true, withBorder: true,
}); });
} }
@ -163,9 +163,9 @@ if (updatedBy) {
} }
#thumbnail { #thumbnail {
max-width: 35rem; max-width: min(35rem, 100%);
max-height: 60vh; max-height: 80vh;
width: 100%; width: auto;
height: auto; height: auto;
border-radius: 16px; border-radius: 16px;
box-shadow: 0 5px 20px -10px var(--color-shadow); box-shadow: 0 5px 20px -10px var(--color-shadow);

View File

@ -42,7 +42,7 @@ const attributes = [
{ {
title: t("global.media.attributes.filename"), title: t("global.media.attributes.filename"),
icon: "material-symbols:audio-file-outline", icon: "material-symbols:audio-file-outline",
values: [filename], values: [{ name: filename }],
withBorder: false, withBorder: false,
}, },
] ]
@ -50,19 +50,19 @@ const attributes = [
{ {
title: t("global.media.attributes.filesize"), title: t("global.media.attributes.filesize"),
icon: "material-symbols:hard-drive-outline", icon: "material-symbols:hard-drive-outline",
values: [formatFilesize(filesize)], values: [{ name: formatFilesize(filesize) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];

View File

@ -32,7 +32,7 @@ const tagsAndAttributes = [
{ {
title: t("global.media.attributes.filename"), title: t("global.media.attributes.filename"),
icon: "material-symbols:unknown-document-outline", icon: "material-symbols:unknown-document-outline",
values: [filename], values: [{ name: filename }],
withBorder: false, withBorder: false,
}, },
] ]
@ -40,13 +40,13 @@ const tagsAndAttributes = [
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];

View File

@ -57,13 +57,13 @@ const attributes = [
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];
@ -72,7 +72,7 @@ if (updatedBy) {
attributes.push({ attributes.push({
title: t("global.media.attributes.updatedBy"), title: t("global.media.attributes.updatedBy"),
icon: "material-symbols:person-edit-outline", icon: "material-symbols:person-edit-outline",
values: [updatedBy?.username], values: [{ name: updatedBy.username }],
withBorder: true, withBorder: true,
}); });
} }
@ -82,7 +82,15 @@ const tagGroupWithAttributes = [
{ {
title: t("collectibles.nature"), title: t("collectibles.nature"),
icon: "material-symbols:leaf-spark-outline", icon: "material-symbols:leaf-spark-outline",
values: [nature === CollectibleNature.Physical ? "Physical" : "Digital"], values: [
{
name: t(
nature === CollectibleNature.Physical
? "collectibles.nature.physical"
: "collectibles.nature.digital"
),
},
],
withBorder: true, withBorder: true,
}, },
]; ];
@ -91,7 +99,7 @@ if (releaseDate) {
tagGroupWithAttributes.push({ tagGroupWithAttributes.push({
title: t("collectibles.releaseDate"), title: t("collectibles.releaseDate"),
icon: "material-symbols:calendar-month-outline", icon: "material-symbols:calendar-month-outline",
values: [formatDate(new Date(releaseDate))], values: [{ name: formatDate(new Date(releaseDate)) }],
withBorder: false, withBorder: false,
}); });
} }
@ -100,7 +108,7 @@ if (languages.length > 0) {
tagGroupWithAttributes.push({ tagGroupWithAttributes.push({
title: t("collectibles.languages"), title: t("collectibles.languages"),
icon: "material-symbols:translate", icon: "material-symbols:translate",
values: languages.map((lang) => formatLocale(lang)), values: languages.map((lang) => ({ name: formatLocale(lang) })),
withBorder: true, withBorder: true,
}); });
} }
@ -122,7 +130,7 @@ if (price) {
tagGroupWithAttributes.push({ tagGroupWithAttributes.push({
title: t("collectibles.price"), title: t("collectibles.price"),
icon: "material-symbols:sell-outline", icon: "material-symbols:sell-outline",
values: [priceText], values: [{ name: priceText }],
withBorder: false, withBorder: false,
}); });
} }
@ -232,7 +240,7 @@ if (price) {
} }
@media (min-width: 52rem) { @media (min-width: 52rem) {
grid-template-columns: 35rem 10rem; grid-template-columns: auto 10rem;
} }
@media (min-width: 1280.5px) { @media (min-width: 1280.5px) {
@ -244,10 +252,15 @@ if (price) {
} }
} }
& a > #thumbnail { & a {
max-width: 35rem; width: fit-content;
width: 100%;
& > #thumbnail {
max-width: min(35rem, 100%);
max-height: 80vh;
width: auto;
height: auto; height: auto;
border-radius: 16px;
box-shadow: 0 5px 20px -10px var(--color-shadow); box-shadow: 0 5px 20px -10px var(--color-shadow);
transition: 100ms scale; transition: 100ms scale;
@ -255,6 +268,7 @@ if (price) {
scale: 102%; scale: 102%;
} }
} }
}
& > #gallery-scans { & > #gallery-scans {
display: flex; display: flex;

View File

@ -27,7 +27,7 @@ const tagsAndAttributes = [
{ {
title: t("global.media.attributes.filename"), title: t("global.media.attributes.filename"),
icon: "material-symbols:unknown-document-outline", icon: "material-symbols:unknown-document-outline",
values: [filename], values: [{ name: filename }],
withBorder: false, withBorder: false,
}, },
] ]
@ -35,13 +35,13 @@ const tagsAndAttributes = [
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];

View File

@ -41,7 +41,7 @@ const attributes = [
{ {
title: t("global.media.attributes.filename"), title: t("global.media.attributes.filename"),
icon: "material-symbols:video-file-outline", icon: "material-symbols:video-file-outline",
values: [filename], values: [{ name: filename }],
withBorder: false, withBorder: false,
}, },
] ]
@ -49,19 +49,19 @@ const attributes = [
{ {
title: t("global.media.attributes.filesize"), title: t("global.media.attributes.filesize"),
icon: "material-symbols:hard-drive-outline", icon: "material-symbols:hard-drive-outline",
values: [formatFilesize(filesize)], values: [{ name: formatFilesize(filesize) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.createdAt"), title: t("global.media.attributes.createdAt"),
icon: "material-symbols:calendar-add-on-outline", icon: "material-symbols:calendar-add-on-outline",
values: [formatDate(new Date(createdAt))], values: [{ name: formatDate(new Date(createdAt)) }],
withBorder: false, withBorder: false,
}, },
{ {
title: t("global.media.attributes.updatedAt"), title: t("global.media.attributes.updatedAt"),
icon: "material-symbols:edit-calendar", icon: "material-symbols:edit-calendar",
values: [formatDate(new Date(updatedAt))], values: [{ name: formatDate(new Date(updatedAt)) }],
withBorder: false, withBorder: false,
}, },
]; ];

View File

@ -33,6 +33,7 @@ export interface Config {
scans: Scan; scans: Scan;
tags: Tag; tags: Tag;
"tags-groups": TagsGroup; "tags-groups": TagsGroup;
attributes: Attribute;
"credits-roles": CreditsRole; "credits-roles": CreditsRole;
recorders: Recorder; recorders: Recorder;
languages: Language; languages: Language;
@ -55,6 +56,7 @@ export interface Page {
slug: string; slug: string;
thumbnail?: string | Image | null; thumbnail?: string | Image | null;
backgroundImage?: string | Image | null; backgroundImage?: string | Image | null;
attributes?: (TagsBlock | NumberBlock | TextBlock)[] | null;
tags?: (string | Tag)[] | null; tags?: (string | Tag)[] | null;
translations: { translations: {
language: string | Language; language: string | Language;
@ -183,6 +185,7 @@ export interface Tag {
id?: string | null; id?: string | null;
}[]; }[];
group: string | TagsGroup; group: string | TagsGroup;
page?: (string | null) | Page;
updatedAt: string; updatedAt: string;
createdAt: string; createdAt: string;
} }
@ -238,6 +241,56 @@ export interface Recorder {
lockUntil?: string | null; lockUntil?: string | null;
password?: string | null; password?: string | null;
} }
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "TagsBlock".
*/
export interface TagsBlock {
name: string | Attribute;
tags: (string | Tag)[];
id?: string | null;
blockName?: string | null;
blockType: "tagsBlock";
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "attributes".
*/
export interface Attribute {
id: string;
slug: string;
icon?: string | null;
type: "Number" | "Text" | "Tags";
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` "NumberBlock".
*/
export interface NumberBlock {
name: string | Attribute;
number: number;
id?: string | null;
blockName?: string | null;
blockType: "numberBlock";
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "TextBlock".
*/
export interface TextBlock {
name: string | Attribute;
text: string;
id?: string | null;
blockName?: string | null;
blockType: "textBlock";
}
/** /**
* This interface was referenced by `Config`'s JSON-Schema * This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "folders". * via the `definition` "folders".
@ -1009,6 +1062,7 @@ export enum Collections {
MediaThumbnails = "media-thumbnails", MediaThumbnails = "media-thumbnails",
Scans = "scans", Scans = "scans",
CreditsRole = "credits-roles", CreditsRole = "credits-roles",
Attributes = "attributes",
} }
export enum CollectionGroups { export enum CollectionGroups {
@ -1065,6 +1119,12 @@ export enum CollectionStatus {
Published = "published", Published = "published",
} }
export enum AttributeTypes {
Number = "Number",
Text = "Text",
Tags = "Tags",
}
/* RICH TEXT */ /* RICH TEXT */
export type RichTextContent = { export type RichTextContent = {
@ -1344,7 +1404,6 @@ const injectAuth = async (init?: RequestInit): Promise<RequestInit> => ({
headers: { headers: {
...init?.headers, ...init?.headers,
Authorization: `JWT ${await getToken()}`, Authorization: `JWT ${await getToken()}`,
"x-rate-limit-skip": import.meta.env.PAYLOAD_RATING_LIMIT_SKIP_TOKEN ?? "",
}, },
}); });
@ -1441,6 +1500,7 @@ export type EndpointWording = {
export type EndpointTag = { export type EndpointTag = {
slug: string; slug: string;
page?: EndpointPage;
translations: { translations: {
language: string; language: string;
name: string; name: string;
@ -1457,6 +1517,35 @@ export type EndpointTagsGroup = {
tags: EndpointTag[]; tags: EndpointTag[];
}; };
export type EndpointGenericAttribute = {
slug: string;
icon: string;
translations: {
language: string;
name: string;
}[];
};
export type EndpointNumberAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Number;
value: number;
};
export type EndpointTextAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Text;
value: string;
};
export type EndpointTagsAttribute = EndpointGenericAttribute & {
type: AttributeTypes.Tags;
value: EndpointTag[];
};
export type EndpointAttribute =
| EndpointNumberAttribute
| EndpointTextAttribute
| EndpointTagsAttribute;
export type EndpointRole = { export type EndpointRole = {
icon: string; icon: string;
translations: { translations: {
@ -1474,6 +1563,7 @@ export type EndpointPage = {
slug: string; slug: string;
thumbnail?: EndpointImage; thumbnail?: EndpointImage;
tagGroups: EndpointTagsGroup[]; tagGroups: EndpointTagsGroup[];
attributes: EndpointAttribute[];
backgroundImage?: EndpointImage; backgroundImage?: EndpointImage;
translations: { translations: {
language: string; language: string;