diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index cce48a7..20578d0 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -11,8 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - with: - ref: main - uses: borales/actions-yarn@v3.0.0 with: diff --git a/package.json b/package.json index 5650a3f..e29fc03 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "alphaday", "private": true, - "version": "1.3.11", + "version": "1.3.12", "homepage": ".", "scripts": { "dev": "vite", diff --git a/src/App.jsx b/src/App.jsx index 0c7aee6..869d63e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -6,6 +6,8 @@ import HomeContainer from "./containers/HomeContainer"; import { CookieProvider } from "./utils/CookieContext"; import PrivacyPolicyPage from "./pages/privacy-policy"; import MobilePage from "./pages/mobile-app"; +import { useEffect } from "react"; +import { navigateToHash } from "./utils/navigateToHash"; function removeTrailingBackSlash(site) { return site.replace(/\/$/, ""); @@ -21,6 +23,22 @@ function App() { const supportedPaths = ["", ...Object.keys(otherPages)]; + // Has navigator - scroll to the hash on the page + useEffect(() => { + // For Vite production builds, wait for all chunks to load + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", () => { + setTimeout(navigateToHash, 100); // Small delay after DOMContentLoaded + }); + } else { + setTimeout(navigateToHash, 100); + } + + window.addEventListener("hashchange", navigateToHash); + + return () => window.removeEventListener("hashchange", navigateToHash); + }, []); + if (!supportedPaths.includes(path)) { if (path.startsWith("/b/")) { window.location.replace(`${CONFIG.alphadayApp}${path}`); diff --git a/src/utils/navigateToHash.js b/src/utils/navigateToHash.js new file mode 100644 index 0000000..a0acfb3 --- /dev/null +++ b/src/utils/navigateToHash.js @@ -0,0 +1,10 @@ +export const navigateToHash = () => { + const hash = window.location.hash.slice(1); + if (!hash) return; + + const element = document.getElementById(hash); + if (element) { + console.log("Found element, scrolling..."); + element.scrollIntoView({ behavior: "smooth", block: "start" }); + } +};