@paroicms/server
Version:
The ParoiCMS server
39 lines • 1.29 kB
JavaScript
import { encodeLNodeId } from "@paroicms/public-anywhere-lib";
import { type } from "arktype";
import { cmsVersion } from "../context.js";
import { getHandleOfFeaturedImage } from "./media-handles.helpers.js";
export const AccountPreferencesAT = type({
"language?": "string|undefined",
"+": "reject",
});
export function formatAuthenticatedAccount(data) {
return {
...formatAccount(data),
preferences: data.preferences ? AccountPreferencesAT.assert(data.preferences) : undefined,
};
}
export function formatAccount(data) {
return {
...data,
hasPasswordResetToken: !!data.passwordResetToken,
};
}
export function toDocumentSeed(document) {
return {
lNodeId: encodeLNodeId({
language: document.language,
nodeId: document.nodeId,
}),
language: document.language,
nodeId: document.nodeId,
metaDescription: document.metaDescription,
title: document.title,
slug: document.slug,
metaKeywords: document.metaKeywords,
featuredImageHandle: getHandleOfFeaturedImage(document.nodeId),
};
}
export function getAssetsBaseUrl(siteContext) {
return `/assets/${siteContext.version ?? cmsVersion}`;
}
//# sourceMappingURL=data-format.js.map