How to use the @paperbits/core/ko/knockout-rendering.createDocument function in @paperbits/core

To help you get started, we’ve selected a few @paperbits/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / api-management-developer-portal / src / publishing / pagePublisher.ts View on Github external
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;
github Azure / api-management-developer-portal / src / publishing / blogPublisher.ts View on Github external
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;
github Azure / api-management-developer-portal / src / publishing / publishing.module.ts View on Github external
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