UNPKG

vue-cms-data

Version:

Applies lazy loading and routing to static cms/html data\

25 lines (24 loc) 786 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.applyTransformations = void 0; var transformations_1 = require("./transformations"); function applyTransformations(html, $vm, settings) { if (settings === void 0) { settings = { localized: true, lazy: true, }; } var parser = new DOMParser(); var body = parser.parseFromString(html, 'text/html').body; // Link localization if (settings.localized) { transformations_1.localizeLinks(body, $vm); } // Image lazyloading if (settings.lazy && $vm.$Lazyload) { transformations_1.lazyloadImages(body, { context: $vm, }); } return Array.from(body.childNodes); } exports.applyTransformations = applyTransformations;