Removed tags from cached payload
This commit is contained in:
parent
ae74a8988f
commit
b06c624d41
|
@ -1,17 +1,22 @@
|
||||||
---
|
---
|
||||||
import Metadata from "components/Metadata.astro";
|
import Metadata from "components/Metadata.astro";
|
||||||
import { getI18n } from "src/i18n/i18n";
|
import { getI18n } from "src/i18n/i18n";
|
||||||
|
import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
slug: string;
|
tagGroup: EndpointTagsGroup;
|
||||||
icon: string;
|
|
||||||
values: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { icon, slug, values } = Astro.props;
|
const {
|
||||||
const { formatTag, formatTagsGroup } = await getI18n(Astro.locals.currentLocale);
|
tagGroup: { icon, translations, tags },
|
||||||
|
} = Astro.props;
|
||||||
|
const { getLocalizedMatch } = await getI18n(Astro.locals.currentLocale);
|
||||||
---
|
---
|
||||||
|
|
||||||
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
||||||
|
|
||||||
<Metadata icon={icon} title={formatTagsGroup(slug)} values={values.map(formatTag)} />
|
<Metadata
|
||||||
|
icon={icon}
|
||||||
|
title={getLocalizedMatch(translations).name}
|
||||||
|
values={tags.map(({ translations }) => getLocalizedMatch(translations).name)}
|
||||||
|
/>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
---
|
---
|
||||||
|
import type { EndpointTagsGroup } from "src/shared/payload/payload-sdk";
|
||||||
import TagGroup from "./TagGroup.astro";
|
import TagGroup from "./TagGroup.astro";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
tagGroups: { slug: string; icon: string; values: string[] }[];
|
tagGroups: EndpointTagsGroup[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tagGroups } = Astro.props;
|
const { tagGroups } = Astro.props;
|
||||||
|
@ -11,7 +12,7 @@ const { tagGroups } = Astro.props;
|
||||||
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
{/* ------------------------------------------- HTML ------------------------------------------- */}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{tagGroups.map((tag) => <TagGroup {...tag} />)}
|
{tagGroups.map((tag) => <TagGroup tagGroup={tag} />)}
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -126,18 +126,6 @@ export const getI18n = async (locale: string) => {
|
||||||
|
|
||||||
const getLocalizedUrl = (url: string): string => `/${locale}${url}`;
|
const getLocalizedUrl = (url: string): string => `/${locale}${url}`;
|
||||||
|
|
||||||
const formatTag = (id: string): string => {
|
|
||||||
const tag = cache.tags.find(({ slug }) => slug === id);
|
|
||||||
if (!tag) return "UNKNOWN";
|
|
||||||
return getLocalizedMatch(tag.translations).name;
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatTagsGroup = (id: string): string => {
|
|
||||||
const tag = cache.tagsGroups.find(({ slug }) => slug === id);
|
|
||||||
if (!tag) return "UNKNOWN";
|
|
||||||
return getLocalizedMatch(tag.translations).name;
|
|
||||||
};
|
|
||||||
|
|
||||||
const formatPrice = (price: { amount: number; currency: string }): string =>
|
const formatPrice = (price: { amount: number; currency: string }): string =>
|
||||||
price.amount.toLocaleString(locale, { style: "currency", currency: price.currency });
|
price.amount.toLocaleString(locale, { style: "currency", currency: price.currency });
|
||||||
|
|
||||||
|
@ -172,8 +160,6 @@ export const getI18n = async (locale: string) => {
|
||||||
t,
|
t,
|
||||||
getLocalizedMatch,
|
getLocalizedMatch,
|
||||||
getLocalizedUrl,
|
getLocalizedUrl,
|
||||||
formatTag,
|
|
||||||
formatTagsGroup,
|
|
||||||
formatPrice,
|
formatPrice,
|
||||||
formatDate,
|
formatDate,
|
||||||
formatInches,
|
formatInches,
|
||||||
|
|
|
@ -1474,12 +1474,11 @@ export type EndpointTag = {
|
||||||
language: string;
|
language: string;
|
||||||
name: string;
|
name: string;
|
||||||
}[];
|
}[];
|
||||||
group: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EndpointTagsGroup = {
|
export type EndpointTagsGroup = {
|
||||||
slug: string;
|
slug: string;
|
||||||
icon?: string;
|
icon: string;
|
||||||
translations: {
|
translations: {
|
||||||
language: string;
|
language: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -1492,7 +1491,7 @@ export type EndpointPagePreview = {
|
||||||
type: PageType;
|
type: PageType;
|
||||||
thumbnail?: PayloadImage;
|
thumbnail?: PayloadImage;
|
||||||
authors: EndpointRecorder[];
|
authors: EndpointRecorder[];
|
||||||
tagGroups: TagGroup[];
|
tagGroups: EndpointTagsGroup[];
|
||||||
translations: {
|
translations: {
|
||||||
language: string;
|
language: string;
|
||||||
pretitle?: string;
|
pretitle?: string;
|
||||||
|
@ -1533,7 +1532,7 @@ export type EndpointCollectiblePreview = {
|
||||||
subtitle?: string;
|
subtitle?: string;
|
||||||
description?: RichTextContent;
|
description?: RichTextContent;
|
||||||
}[];
|
}[];
|
||||||
tagGroups: TagGroup[];
|
tagGroups: EndpointTagsGroup[];
|
||||||
status: "draft" | "published";
|
status: "draft" | "published";
|
||||||
releaseDate?: string;
|
releaseDate?: string;
|
||||||
languages: string[];
|
languages: string[];
|
||||||
|
@ -1599,8 +1598,6 @@ export type EndpointCollectible = EndpointCollectiblePreview & {
|
||||||
parentPages: ParentPage[];
|
parentPages: ParentPage[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TagGroup = { slug: string; icon: string; values: string[] };
|
|
||||||
|
|
||||||
export type TableOfContentEntry = {
|
export type TableOfContentEntry = {
|
||||||
prefix: string;
|
prefix: string;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
import {
|
import { payload, type Language, type EndpointWording } from "src/shared/payload/payload-sdk";
|
||||||
payload,
|
|
||||||
type Language,
|
|
||||||
type EndpointTag,
|
|
||||||
type EndpointTagsGroup,
|
|
||||||
type EndpointWording,
|
|
||||||
} from "src/shared/payload/payload-sdk";
|
|
||||||
|
|
||||||
type Cache = {
|
type Cache = {
|
||||||
locales: Language[];
|
locales: Language[];
|
||||||
currencies: string[];
|
currencies: string[];
|
||||||
wordings: EndpointWording[];
|
wordings: EndpointWording[];
|
||||||
tags: EndpointTag[];
|
|
||||||
tagsGroups: EndpointTagsGroup[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchNewData = async (): Promise<Cache> => ({
|
const fetchNewData = async (): Promise<Cache> => ({
|
||||||
locales: await payload.getLanguages(),
|
locales: await payload.getLanguages(),
|
||||||
currencies: (await payload.getCurrencies()).map(({ id }) => id),
|
currencies: (await payload.getCurrencies()).map(({ id }) => id),
|
||||||
tags: await payload.getTags(),
|
|
||||||
tagsGroups: await payload.getTagsGroups(),
|
|
||||||
wordings: await payload.getWordings(),
|
wordings: await payload.getWordings(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue