Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
ref: main
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only deploys from main. Regardless which branch you mention in the deploy action. But most times when we want quick fixes in the frontend. we deploy from a hot-fix/ branch


- uses: borales/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alphaday",
"private": true,
"version": "1.3.11",
"version": "1.3.12",
"homepage": ".",
"scripts": {
"dev": "vite",
Expand Down
18 changes: 18 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\/$/, "");
Expand All @@ -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}`);
Expand Down
10 changes: 10 additions & 0 deletions src/utils/navigateToHash.js
Original file line number Diff line number Diff line change
@@ -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" });
}
};
Loading