Files
klz-cables.com/.pnpm-store/v10/files/d8/f836495a640e52d731cf4cc2b470b137ad71edebb130377941820e3c516d547dea33c7bda9a67122429fa9c53e06ea5a2248c088fd4e90c4645877a2772078
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

33 lines
902 B
Plaintext

/**
* Takes the incoming sort argument and prefixes it with `versions.` and preserves any `-` prefixes for descending order
* @param sort
*/ export const getQueryDraftsSort = ({ collectionConfig, sort })=>{
if (!sort) {
if (collectionConfig.defaultSort) {
sort = collectionConfig.defaultSort;
} else {
sort = '-createdAt';
}
}
if (typeof sort === 'string') {
sort = [
sort
];
}
return sort.map((field)=>{
let orderBy;
let direction = '';
if (field[0] === '-') {
orderBy = field.substring(1);
direction = '-';
} else {
orderBy = field;
}
if (orderBy === 'id') {
return `${direction}parent`;
}
return `${direction}version.${orderBy}`;
});
};
//# sourceMappingURL=getQueryDraftsSort.js.map