2.5.2 • Published 4 years ago
szig-embed v2.5.2
szig-embed
embed library for iframe and inline embeds (within sz)
Next refactoring steps
- add optional (sz) context helper
- separate context-helper by type (homepage, article) and by channel (app, www, mobile)
- simplify api (additional helper around embed-scripts)
basic usage
iframe embed
// in embed.js
(function () {
// run the iframe-embed script
require("szig-embed/lib/iframe/embed").bootstrap();
}());
// in index.js (application side)
var application = require("./application/application.js");
var ViewportService = require("szig-frontend-toolkit/lib/services/ViewportService");
// fetch the embed-service, initialize parent communication and add default height watcher
var EmbedService = require("szig-embed/lib/iframe/service");
EmbedService.init();
EmbedService.observe(ViewportService, ViewportService.END_EVENT);
// run app on DOMContentLoaded, passing embed interface
application(EmbedService);
inline embed
// in embed.js
(function () {
// inject css
require("../src/embed.scss");
// fetch application code and markup
var app = require("../src/application/application");
var pageContent = require("../src/application/application.hbs");
// and run application
require("szig-embed/lib/inline/embed")
.init(pageContent, app)
// app will be called with EmbedService
.bootstrap();
}());
required webpack-config
For inline embeds, relative urls have to be bent to absolute urls. This is done within the inline-embed-helper
. In order to identify the corresponding urls, the webpack setting publicPath has to be set with
publicPath: env.EMBED ? "EMBED://" : ""
2.5.2
4 years ago