UNPKG

@rnaga/wp-node

Version:

👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**

40 lines (39 loc) • 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.definePostTypeFromDirectory = exports.definePostType = void 0; const files_1 = require("../files"); const definePostType = (args) => { let postTypeObject = {}; for (const [name, settings] of Object.entries(args)) { postTypeObject = { ...postTypeObject, [name]: { capabilityType: settings?.capabilityType ?? "post", supports: (settings?.supports ?? [ "title", "editor", "author", "thumbnail", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "post-formats", ]), public: settings?.public ?? true, deleteWithUser: settings?.deleteWithUser ?? true, mapMetaCap: settings?.mapMetaCap ?? true, showInRest: settings?.showInRest ?? true, _builtin: false, }, }; } return postTypeObject; }; exports.definePostType = definePostType; const definePostTypeFromDirectory = (directory) => { const json = (0, files_1.readJsonFiles)(directory); return json ? (0, exports.definePostType)(json) : undefined; }; exports.definePostTypeFromDirectory = definePostTypeFromDirectory;