UNPKG

@curvenote/cli-plugin

Version:
50 lines (49 loc) 2 kB
import { validateStringOptions, makePlaceholder } from '../utils.js'; export const collectionsDirective = { name: 'cn:collections', doc: 'Create a listing of all collections available in the venue.', options: { venue: { type: String, doc: 'The venue to list collections from.', required: true, }, filter: { type: String, doc: 'The status of collections to list (open | closed | all).', required: false, }, exclude: { type: String, doc: 'Collections to ignore, by name and comma separated.', required: false, }, 'show-count': { type: Boolean, doc: 'If set to true, the number of items in the collection will be shown.', required: false, }, }, validate(data, vfile) { var _a, _b, _c, _d; if (!((_a = data.options) === null || _a === void 0 ? void 0 : _a.venue)) { vfile.message('A venue must be supplied.'); } if (((_b = data.options) === null || _b === void 0 ? void 0 : _b.exclude) && typeof ((_c = data.options) === null || _c === void 0 ? void 0 : _c.exclude) !== 'string') { vfile.message('exclude list should be a string of comma separated collection names.'); } validateStringOptions(vfile, 'show', (_d = data.options) === null || _d === void 0 ? void 0 : _d.show, ['open', 'closed', 'all']); return data; }, run(data) { var _a, _b, _c; return [ { type: 'curvenoteCollections', ...data.options, show: (_b = (_a = data.options) === null || _a === void 0 ? void 0 : _a.show) !== null && _b !== void 0 ? _b : 'all', children: makePlaceholder(data, `a live listing of collectons from ${(_c = data.options) === null || _c === void 0 ? void 0 : _c.venue}`), }, ]; }, };