UNPKG

@nexo-labs/payload-taxonomies

Version:
59 lines (56 loc) 1.39 kB
import { t as COLLECTION_SLUG_TAXONOMY } from "./constants-ahxpHht8.mjs"; import { slugField } from "payload"; //#region src/taxonomiesRelationshipFields.ts const buildTaxonomyRelationship = (field) => ({ name: field?.name ?? "categories", label: field?.label ?? "Categorías", type: "relationship", defaultValue: field?.defaultValue ?? [], filterOptions: field?.filterOptions, required: field?.required ?? false, hasMany: true, relationTo: COLLECTION_SLUG_TAXONOMY }); //#endregion //#region src/taxonomy.ts const taxonomiesCollection = ({ payloadTypescriptSchema, ...config }) => ({ ...config, slug: COLLECTION_SLUG_TAXONOMY, labels: { singular: "Taxonomia", plural: "Taxonomias", ...config.labels }, admin: { useAsTitle: "name", group: "Contenido", defaultColumns: [ "name", "parent", "payload" ], ...config.admin }, fields: [ { name: "name", label: "Nombre", type: "text", localized: true, required: true }, slugField({ useAsSlug: "name" }), { name: "payload", label: "Payload Adicional", type: "json", required: false, typescriptSchema: payloadTypescriptSchema, admin: { description: "Metadata: types, permissions, selectable, etc." } }, ...config.fields ?? [] ] }); //#endregion export { COLLECTION_SLUG_TAXONOMY, buildTaxonomyRelationship, taxonomiesCollection }; //# sourceMappingURL=index.mjs.map