@botonic/plugin-contentful
Version:
## What Does This Plugin Do?
44 lines • 1.59 kB
JavaScript
import * as cms from './cms';
import { LogCMS } from './cms';
import { Contentful } from './contentful/cms-contentful';
import { Normalizer } from './nlp';
import { BotonicMsgConverter } from './render';
import { Search } from './search';
export const DEFAULT_TIMEOUT_MS = 30000;
export const DEFAULT_CACHE_TTL_MS = 10000;
export const DEFAULT_FALLBACK_CACHE_LIMIT_KB = 100 * 1024;
export default class BotonicPluginContentful {
constructor(opt) {
const optionsAny = opt;
if (optionsAny.cms) {
this.cms = optionsAny.cms;
}
else {
const contOptions = opt;
const factory = contOptions.contentfulFactory ||
(o => {
let cms = new Contentful(o);
if (contOptions.logCalls) {
cms = new LogCMS(cms, contOptions);
}
return cms;
});
this.cms = factory(contOptions);
}
this.cms = new cms.ErrorReportingCMS(this.cms, opt.logger);
this.renderer = opt.renderer || new BotonicMsgConverter();
if (opt.search) {
this.search = opt.search;
this.normalizer = opt.normalizer || new Normalizer();
}
else {
this.normalizer = opt.nlpOptions
? new Normalizer(opt.nlpOptions.blackList)
: new Normalizer();
this.search = new Search(this.cms, this.normalizer, opt.keywordsOptions);
}
}
pre(_r) { }
post(_r) { }
}
//# sourceMappingURL=plugin.js.map