Files
bitvid/dist/js/hashView.js
T
google-labs-jules[bot]andPR0M3TH3AN 0bfa3b08e8 fix(ci): fix netlify deployment by building to dist
- Move from root publishing to clean `dist/` directory
- Create `scripts/build-dist.mjs` to orchestrate build and copy assets
- Update `package.json` build script
- Update `netlify.toml` to publish `dist/`
- Ignore `dist/` in `.gitignore`

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-01-29 09:07:15 +00:00

36 lines
899 B
JavaScript

// js/hashView.js
const HASH_VIEW_REGEX = /^#view=([^&]+)/;
export function getHashViewName() {
const hash = typeof window !== "undefined" ? window.location.hash || "" : "";
const match = hash.match(HASH_VIEW_REGEX);
const viewName = match?.[1];
if (typeof viewName !== "string") {
return "";
}
return viewName.trim();
}
export function setHashView(viewName, options = {}) {
if (typeof window === "undefined") {
return;
}
const url = new URL(window.location.href);
url.searchParams.delete("modal");
if (!options?.preserveVideoParam) {
url.searchParams.delete("v");
}
const newUrl = url.pathname + url.search + `#view=${viewName}`;
window.history.replaceState({}, "", newUrl);
if (typeof HashChangeEvent === "function") {
window.dispatchEvent(new HashChangeEvent("hashchange"));
} else {
window.dispatchEvent(new Event("hashchange"));
}
}