UNPKG

@botonic/plugin-contentful

Version:

Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet

32 lines 1.32 kB
import { __awaiter } from "tslib"; import * as cms from '../../cms'; import { addCustomFields, ContentfulEntryUtils, } from '../delivery-utils'; import { getTargetCallback } from './callback-delivery'; import { DeliveryWithReference } from './reference'; export class InputDelivery extends DeliveryWithReference { constructor(delivery, resumeErrors) { super(cms.ContentType.INPUT, delivery, resumeErrors); } input(id, context) { return __awaiter(this, void 0, void 0, function* () { const entry = yield this.getEntry(id, context); return this.fromEntry(entry, context); }); } fromEntry(entry, context) { const fields = entry.fields; const common = ContentfulEntryUtils.commonFieldsFromEntry(entry); const referenceDelivery = { delivery: this.reference, context, }; return addCustomFields(new cms.Input(common, fields.title, fields.keywords, this.target(entry, context), fields.type), entry.fields, referenceDelivery); } target(entry, context) { if (!entry.fields.target) { throw new cms.CmsException(`Input ${this.entryId(entry)} has no target`); } return getTargetCallback(entry.fields.target, context); } } //# sourceMappingURL=input.js.map