Remove recorders from cached payload content
This commit is contained in:
parent
3c7ce915f1
commit
24f8e72fe9
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
import { formatRecorder } from "src/utils/format";
|
||||
import type { EndpointRecorder } from "src/shared/payload/payload-sdk";
|
||||
import Metadata from "./Metadata.astro";
|
||||
|
||||
interface Props {
|
||||
translators?: string[] | undefined;
|
||||
transcribers?: string[] | undefined;
|
||||
proofreaders?: string[] | undefined;
|
||||
translators?: EndpointRecorder[] | undefined;
|
||||
transcribers?: EndpointRecorder[] | undefined;
|
||||
proofreaders?: EndpointRecorder[] | undefined;
|
||||
}
|
||||
|
||||
const { translators = [], transcribers = [], proofreaders = [] } = Astro.props;
|
||||
|
@ -16,17 +16,17 @@ const { translators = [], transcribers = [], proofreaders = [] } = Astro.props;
|
|||
<Metadata
|
||||
icon="material-symbols:person-outline"
|
||||
title="Translators"
|
||||
values={translators.map((id) => formatRecorder(id))}
|
||||
values={translators.map(({ username }) => username)}
|
||||
/>
|
||||
|
||||
<Metadata
|
||||
icon="material-symbols:person-edit-outline"
|
||||
title="Transcribers"
|
||||
values={transcribers.map((id) => formatRecorder(id))}
|
||||
values={transcribers.map(({ username }) => username)}
|
||||
/>
|
||||
|
||||
<Metadata
|
||||
icon="material-symbols:person-check-outline"
|
||||
title="Proofreaders"
|
||||
values={proofreaders.map((id) => formatRecorder(id))}
|
||||
values={proofreaders.map(({ username }) => username)}
|
||||
/>
|
||||
|
|
|
@ -1491,7 +1491,7 @@ export type EndpointPagePreview = {
|
|||
slug: string;
|
||||
type: PageType;
|
||||
thumbnail?: PayloadImage;
|
||||
authors: string[];
|
||||
authors: EndpointRecorder[];
|
||||
tagGroups: TagGroup[];
|
||||
translations: {
|
||||
language: string;
|
||||
|
@ -1508,9 +1508,9 @@ export type EndpointPage = EndpointPagePreview & {
|
|||
sourceLanguage: string;
|
||||
summary?: RichTextContent;
|
||||
content: RichTextContent;
|
||||
transcribers: string[];
|
||||
translators: string[];
|
||||
proofreaders: string[];
|
||||
transcribers: EndpointRecorder[];
|
||||
translators: EndpointRecorder[];
|
||||
proofreaders: EndpointRecorder[];
|
||||
toc: TableOfContentEntry[];
|
||||
})[];
|
||||
parentPages: ParentPage[];
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
payload,
|
||||
type EndpointRecorder,
|
||||
type Language,
|
||||
type EndpointTag,
|
||||
type EndpointTagsGroup,
|
||||
|
@ -10,16 +9,14 @@ import {
|
|||
type Cache = {
|
||||
locales: Language[];
|
||||
currencies: string[];
|
||||
recorders: EndpointRecorder[];
|
||||
wordings: EndpointWording[];
|
||||
tags: EndpointTag[];
|
||||
tagsGroups: EndpointTagsGroup[];
|
||||
wordings: EndpointWording[];
|
||||
};
|
||||
|
||||
const fetchNewData = async (): Promise<Cache> => ({
|
||||
locales: await payload.getLanguages(),
|
||||
currencies: (await payload.getCurrencies()).map(({ id }) => id),
|
||||
recorders: await payload.getRecorders(),
|
||||
tags: await payload.getTags(),
|
||||
tagsGroups: await payload.getTagsGroups(),
|
||||
wordings: await payload.getWordings(),
|
||||
|
|
|
@ -3,16 +3,6 @@ import { cache } from "src/utils/cachedPayload";
|
|||
export const formatLocale = (code: string): string =>
|
||||
cache.locales.find(({ id }) => id === code)?.name ?? code;
|
||||
|
||||
export const formatRecorder = (recorderId: string): string => {
|
||||
const result = cache.recorders.find(({ id }) => id === recorderId);
|
||||
|
||||
if (!result) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
return result.username;
|
||||
};
|
||||
|
||||
export const formatInlineTitle = ({
|
||||
pretitle,
|
||||
title,
|
||||
|
|
Loading…
Reference in New Issue