Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async renderPage(page: PageContract, settings: SettingsContract, iconMedia: MediaContract, imageMedia: MediaContract): Promise<{ permalink, bytes }> {
console.log(`Publishing page ${page.title}...`);
const templateDocument = createDocument(template);
let permalink = page.permalink;
let htmlContent: string;
const buildContentPromise = new Promise(async (resolve, reject) => {
const layoutViewModel = await this.layoutViewModelBinder.getLayoutViewModel(page.permalink, null);
ko.applyBindingsToNode(templateDocument.body, { widget: layoutViewModel }, null);
if (page.ogImageSourceKey) {
imageMedia = await this.mediaService.getMediaByKey(page.ogImageSourceKey);
}
this.setSiteSettings(templateDocument, settings, iconMedia, imageMedia, page, page.permalink);
setTimeout(() => {
htmlContent = "" + templateDocument.documentElement.outerHTML;
private async renderBlogPost(post: BlogPostContract, settings: SettingsContract, iconFile: MediaContract): Promise<{ name, bytes }> {
console.log(`Publishing blog post ${post.title}...`);
const templateDocument = createDocument(template);
let resourceUri: string;
let htmlContent: string;
const buildContentPromise = new Promise(async (resolve, reject) => {
const layoutViewModel = await this.layoutViewModelBinder.getLayoutViewModel(post.permalink, null);
ko.applyBindingsToNode(templateDocument.body, { widget: layoutViewModel }, null);
setTimeout(() => {
this.setSiteSettings(templateDocument, settings, iconFile, post);
htmlContent = "" + templateDocument.documentElement.outerHTML;
resolve();
}, 500);
});
await buildContentPromise;
public register(injector: IInjector): void {
createDocument();
injector.bindSingleton("sitePublisher", SitePublisher);
injector.bindSingleton("assetPublisher", AssetPublisher);
injector.bindSingleton("pagePublisher", PagePublisher);
injector.bindSingleton("mediaPublisher", MediaPublisher);
const stylePublisher = injector.resolve("stylePublisher");
const pagePublisher = injector.resolve("pagePublisher");
const mediaPublisher = injector.resolve("mediaPublisher");
const assetPublisher = injector.resolve("assetPublisher");
injector.bindInstance("publishers", [
stylePublisher,
assetPublisher,
mediaPublisher,
pagePublisher