UNPKG

@paroicms/connector

Version:

An API to help build management tools for ParoiCMS instances

15 lines 612 B
export function parseSorting(val) { if (val === "manual") return "manual"; const regularChildrenSorting = []; const arr = typeof val === "string" ? val.split(/\s*,\s*/) : val; for (const item of arr) { const [fieldName, direction] = item.split(/\s+/); if ((direction !== "asc" && direction !== "desc") || !/^[a-zA-Z]+$/.test(fieldName)) { throw new Error(`invalid child ordering '${item}'`); } regularChildrenSorting.push([fieldName, direction]); } return regularChildrenSorting; } //# sourceMappingURL=site-schema-public-helpers.js.map