diff --git a/frontend/static/js/index.js b/frontend/static/js/index.js index f63c27c..5172ded 100644 --- a/frontend/static/js/index.js +++ b/frontend/static/js/index.js @@ -2,6 +2,7 @@ import Dashboard from "./views/Dashboard.js"; import Posts from "./views/Posts.js"; import PostView from "./views/PostView.js"; import Settings from "./views/Settings.js"; +import Chat from "./views/Chat.js"; const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$"); @@ -24,7 +25,8 @@ const router = async () => { { path: "/", view: Dashboard }, { path: "/posts", view: Posts }, { path: "/posts/:id", view: PostView }, - { path: "/settings", view: Settings } + { path: "/settings", view: Settings }, + { path: "/chat", view: Chat }, ]; // Test each route for potential match @@ -47,6 +49,8 @@ const router = async () => { const view = new match.route.view(getParams(match)); document.querySelector("#app").innerHTML = await view.getHtml(); + + await view.postInit(); }; window.addEventListener("popstate", router); @@ -60,4 +64,4 @@ document.addEventListener("DOMContentLoaded", () => { }); router(); -}); \ No newline at end of file +}); diff --git a/frontend/static/js/views/AbstractView.js b/frontend/static/js/views/AbstractView.js index 18bf83f..f9f699b 100644 --- a/frontend/static/js/views/AbstractView.js +++ b/frontend/static/js/views/AbstractView.js @@ -3,6 +3,9 @@ export default class { this.params = params; } + async postInit() { + } + setTitle(title) { document.title = title; } @@ -10,4 +13,4 @@ export default class { async getHtml() { return ""; } -} \ No newline at end of file +}