From 62fd792380c53fa63699e8ae0c48d693d78394ba Mon Sep 17 00:00:00 2001 From: bobinstein Date: Mon, 9 Sep 2024 17:29:34 -0400 Subject: [PATCH] chore: Made redirecting .html links work. Tentatively --- docs/package.json | 3 +- docs/src/.vuepress/enhanceApp.js | 67 ++++++++++--------- .../theme/configs/default_sidebar_config.js | 2 +- .../gateways/ar-io-node/arnsoip/observer.md | 2 +- firebase.json | 7 ++ 5 files changed, 47 insertions(+), 34 deletions(-) diff --git a/docs/package.json b/docs/package.json index eb134a25..6e2e0c1a 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,8 @@ "dev": "vuepress dev src", "build": "vuepress build src", "build-gh": "cross-env BASE_URL=/docs/ vuepress build src", - "deploy": "permaweb-deploy --deploy-folder ./src/.vuepress/dist --ant-process $DEPLOY_ANT_PROCESS_ID" + "deploy": "permaweb-deploy --deploy-folder ./src/.vuepress/dist --ant-process $DEPLOY_ANT_PROCESS_ID", + "fire-test": "yarn build && firebase deploy" }, "license": "MIT", "devDependencies": { diff --git a/docs/src/.vuepress/enhanceApp.js b/docs/src/.vuepress/enhanceApp.js index 78e168e2..319e13ed 100644 --- a/docs/src/.vuepress/enhanceApp.js +++ b/docs/src/.vuepress/enhanceApp.js @@ -3,8 +3,8 @@ * * https://v1.vuepress.vuejs.org/guide/basic-config.html#app-level-enhancements */ -import Vue from 'vue'; -import store from './store'; +import Vue from "vue"; +import store from "./store"; export default ({ Vue, // the version of Vue being used in the VuePress app @@ -19,41 +19,46 @@ export default ({ }, }); - router.beforeEach((to, from, next) => { - // List of redirects (old path to new path) - const redirects = { - '/arcss': '/wayfinder', // Add more as needed - '/gateways/ar-io-node/arnsoip/observer.html': '/gateways/ar-io-node/arnsoip/observer' - }; + if (typeof window !== "undefined") { + console.log("latest enhanced loaded"); + router.beforeEach((to, from, next) => { + // List of redirects (old path to new path) + const redirects = { + "/arcss": "/wayfinder", // Add more as needed + "/gateways/ar-io-node/arnsoip/observer.html": + "/gateways/ar-io-node/arnsoip/observer", + }; - // Normalize the path by removing any trailing slash for easier matching - const normalizedPath = to.path.replace(/\/$/, ''); + // Normalize the path by removing any trailing slash for easier matching + const normalizedPath = to.path.replace(/\/$/, ""); - let redirectPath = redirects[normalizedPath]; + let redirectPath = redirects[normalizedPath]; - // Only check for the staging environment in the browser - if (typeof window !== 'undefined') { - const isStaging = window.location.hostname === 'ar-io.github.io'; + // Only check for the staging environment in the browser + if (typeof window !== "undefined") { + const isStaging = window.location.hostname === "ar-io.github.io"; - // Adjust the redirect paths based on the base URL for staging - if (redirectPath && isStaging) { - redirectPath = `/docs${redirectPath}`; + // Adjust the redirect paths based on the base URL for staging + if (redirectPath && isStaging) { + redirectPath = `/docs${redirectPath}`; + } + + // Specific handling for `.html` pages to force a reload + if (normalizedPath.endsWith(".html") && redirectPath) { + window.location.href = redirectPath + (to.hash || ""); + window.location.reload() + // return; // Ensure further navigation is prevented after reload + } } - // Specific handling for `.html` pages to force a reload - if (normalizedPath.endsWith('.html') && redirectPath) { - window.location.href = redirectPath + (to.hash || ''); - return; // Ensure further navigation is prevented after reload + if (redirectPath) { + // For regular non-`.html` redirects + window.location.replace(redirectPath + (to.hash || "")); + } else { + next(); // Proceed to the requested page if no redirect is found } - } - - if (redirectPath) { - // For regular non-`.html` redirects - window.location.replace(redirectPath + (to.hash || '')); - } else { - next(); // Proceed to the requested page if no redirect is found - } - }); + }); + } // ...apply other enhancements for the site. -} +}; diff --git a/docs/src/.vuepress/theme/configs/default_sidebar_config.js b/docs/src/.vuepress/theme/configs/default_sidebar_config.js index 66b217bd..d8699586 100644 --- a/docs/src/.vuepress/theme/configs/default_sidebar_config.js +++ b/docs/src/.vuepress/theme/configs/default_sidebar_config.js @@ -36,7 +36,7 @@ module.exports = [ }, { title: "Observation and Incentive Protocol", - path: "/gateways/ar-io-node/arnsoip/observer", + path: "/gateways/ar-io-node/arnsoip/observer.md", }, ], }, diff --git a/docs/src/gateways/ar-io-node/arnsoip/observer.md b/docs/src/gateways/ar-io-node/arnsoip/observer.md index 887ab392..1ab68a49 100644 --- a/docs/src/gateways/ar-io-node/arnsoip/observer.md +++ b/docs/src/gateways/ar-io-node/arnsoip/observer.md @@ -1,5 +1,5 @@ --- -permalink: "/gateways/ar-io-node/arnsoip/observer" +permalink: "/gateways/ar-io-node/arnsoip/observer/" next: false --- diff --git a/firebase.json b/firebase.json index 6696a1f0..d2a06bcc 100644 --- a/firebase.json +++ b/firebase.json @@ -5,6 +5,13 @@ "firebase.json", "**/.*", "**/node_modules/**" + ], + "redirects": [ + { + "source": "/gateways/ar-io-node/arnsoip/observer.html", + "destination": "/gateways/ar-io-node/arnsoip/observer", + "type": 301 + } ] } }