import { Content, TypedContent } from "../../../model/content"; import "./content.scss"; import { PageElement } from "../../../framework/page-element"; import { createElement } from "../../../framework/element-factory"; export class PageContent extends PageElement { private static isTyped(content): content is TypedContent { return (content as TypedContent).type !== undefined; } public constructor(content: Content) { super(); this.setElement( createElement(`
${content .map(element => { if (PageContent.isTyped(element)) { if (element.type === "a") { return ` ${element.text} `; } if (element.type === "video") { return ``; } throw new Error("Unhandled type."); } return `

${element}

`; }) .join("\n")}
`) ); } }