forked from FWS/TEMPLATE-Web-site-one-page
fix(router): keep html entrypoints working
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
(() => {
|
(() => {
|
||||||
const main = document.getElementById("app-main");
|
const main = document.getElementById("app-main");
|
||||||
|
const footerYear = document.getElementById("footer-year");
|
||||||
const pageStyleSelectors = "[data-page-style='true']";
|
const pageStyleSelectors = "[data-page-style='true']";
|
||||||
|
|
||||||
const links = Array.from(document.querySelectorAll("[data-route]"));
|
const links = Array.from(document.querySelectorAll("[data-route]"));
|
||||||
|
|
||||||
|
if (footerYear) {
|
||||||
|
footerYear.textContent = new Date().getFullYear().toString();
|
||||||
|
}
|
||||||
|
|
||||||
function clearInjectedPageStyles() {
|
function clearInjectedPageStyles() {
|
||||||
document.querySelectorAll(pageStyleSelectors).forEach((node) => node.remove());
|
document.querySelectorAll(pageStyleSelectors).forEach((node) => node.remove());
|
||||||
}
|
}
|
||||||
@@ -59,6 +64,10 @@
|
|||||||
|
|
||||||
const path = window.location.pathname.replace(/^\/+|\/+$/g, "");
|
const path = window.location.pathname.replace(/^\/+|\/+$/g, "");
|
||||||
if (path) {
|
if (path) {
|
||||||
|
if (path.endsWith(".html")) {
|
||||||
|
return "index";
|
||||||
|
}
|
||||||
|
|
||||||
const parts = path.split("/");
|
const parts = path.split("/");
|
||||||
if (parts[0] === "p" && parts[1]) {
|
if (parts[0] === "p" && parts[1]) {
|
||||||
return normalizeRoute(parts.slice(1).join("/"));
|
return normalizeRoute(parts.slice(1).join("/"));
|
||||||
|
|||||||
Reference in New Issue
Block a user