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

47 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchResult = exports.SearchCandidate = void 0; const cms_1 = require("../cms"); const cms_2 = require("../cms/cms"); class SearchCandidate { /** * @param contentId It may be a {@link Callback}'s with an URL instead of payload */ constructor(contentId, common, priority = cms_1.PRIORITY_MAX) { this.contentId = contentId; this.common = common; this.priority = priority; } withResult(match, score) { return new SearchResult(this, match, score); } } exports.SearchCandidate = SearchCandidate; class SearchResult extends SearchCandidate { /** * @param match part of the input which match against a recognized text */ constructor(candidate, match, score) { super(candidate.contentId, candidate.common, candidate.priority); this.match = match; this.score = score; } toButton() { let shortText = this.common.shortText; if (!shortText) { shortText = this.common.name; console.error(`${JSON.stringify(this.contentId)} ${this.common.name} without shortText. Assigning name to button text`); } return new cms_1.Button(this.common.name, this.common.name, shortText, cms_1.ContentCallback.ofContentId(this.contentId)); } getCallbackIfChitchat() { if (this.common.shortText !== SearchResult.CHITCHAT_SHORT_TEXT && this.contentId.model !== cms_2.ContentType.CHITCHAT) { return undefined; } return this.contentId; } } exports.SearchResult = SearchResult; SearchResult.CHITCHAT_SHORT_TEXT = 'chitchat'; //# sourceMappingURL=search-result.js.map