Files
klz-cables.com/.pnpm-store/v10/files/a7/64b83ac48f2b9947fbd2737e9f2f61efce2893924dcf0e2f52bb28f7e22e0d9b80f5f03fcb17e2f58b9690f901c973f5b3dfb6625148c2aac50a4cdaf3b71e
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

48 lines
1.3 KiB
Plaintext

import { hasDraftsEnabled } from '../utilities/getVersionsConfig.js';
export const getLatestGlobalVersion = async ({ slug, config, locale, payload, published, req, where })=>{
let latestVersion;
const whereQuery = published ? {
'version._status': {
equals: 'published'
}
} : {
latest: {
equals: true
}
};
if (hasDraftsEnabled(config)) {
latestVersion = (await payload.db.findGlobalVersions({
global: slug,
limit: 1,
locale: locale || req?.locale || undefined,
pagination: false,
req,
where: whereQuery
})).docs[0];
}
const global = await payload.db.findGlobal({
slug,
locale,
req,
where
});
const globalExists = Boolean(global);
if (!latestVersion) {
return {
global,
globalExists
};
}
if (!latestVersion.version.createdAt) {
latestVersion.version.createdAt = latestVersion.createdAt;
}
if (!latestVersion.version.updatedAt) {
latestVersion.version.updatedAt = latestVersion.updatedAt;
}
return {
global: latestVersion.version,
globalExists
};
};
//# sourceMappingURL=getLatestGlobalVersion.js.map