Add PostInit in index.js/AbstractViews.js
This commit is contained in:
parent
b95bed8894
commit
8202a8b88d
@ -2,6 +2,7 @@ import Dashboard from "./views/Dashboard.js";
|
|||||||
import Posts from "./views/Posts.js";
|
import Posts from "./views/Posts.js";
|
||||||
import PostView from "./views/PostView.js";
|
import PostView from "./views/PostView.js";
|
||||||
import Settings from "./views/Settings.js";
|
import Settings from "./views/Settings.js";
|
||||||
|
import Chat from "./views/Chat.js";
|
||||||
|
|
||||||
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
|
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
|
||||||
|
|
||||||
@ -24,7 +25,8 @@ const router = async () => {
|
|||||||
{ path: "/", view: Dashboard },
|
{ path: "/", view: Dashboard },
|
||||||
{ path: "/posts", view: Posts },
|
{ path: "/posts", view: Posts },
|
||||||
{ path: "/posts/:id", view: PostView },
|
{ path: "/posts/:id", view: PostView },
|
||||||
{ path: "/settings", view: Settings }
|
{ path: "/settings", view: Settings },
|
||||||
|
{ path: "/chat", view: Chat },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Test each route for potential match
|
// Test each route for potential match
|
||||||
@ -47,6 +49,8 @@ const router = async () => {
|
|||||||
const view = new match.route.view(getParams(match));
|
const view = new match.route.view(getParams(match));
|
||||||
|
|
||||||
document.querySelector("#app").innerHTML = await view.getHtml();
|
document.querySelector("#app").innerHTML = await view.getHtml();
|
||||||
|
|
||||||
|
await view.postInit();
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("popstate", router);
|
window.addEventListener("popstate", router);
|
||||||
|
@ -3,6 +3,9 @@ export default class {
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async postInit() {
|
||||||
|
}
|
||||||
|
|
||||||
setTitle(title) {
|
setTitle(title) {
|
||||||
document.title = title;
|
document.title = title;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user