Move collection description rendering to JSON (#6944)
* First pass, moving collection description rendering to JSON * tsc * docs * refactor * test
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
import Collection from "@server/models/Collection";
|
||||
import { DocumentHelper } from "@server/models/helpers/DocumentHelper";
|
||||
import { APIContext } from "@server/types";
|
||||
|
||||
export default async function presentCollection(
|
||||
ctx: APIContext | undefined,
|
||||
collection: Collection
|
||||
) {
|
||||
const asData = !ctx || Number(ctx?.headers["x-api-version"] ?? 0) >= 3;
|
||||
|
||||
export default function presentCollection(collection: Collection) {
|
||||
return {
|
||||
id: collection.id,
|
||||
url: collection.url,
|
||||
urlId: collection.urlId,
|
||||
name: collection.name,
|
||||
description: collection.description,
|
||||
data: asData ? await DocumentHelper.toJSON(collection) : undefined,
|
||||
description: asData ? undefined : collection.description,
|
||||
sort: collection.sort,
|
||||
icon: collection.icon,
|
||||
index: collection.index,
|
||||
|
||||
Reference in New Issue
Block a user