mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2025-09-08 15:08:44 +00:00
added better markdown view pages and enabled subscription button to know when your logged in
This commit is contained in:
@@ -1,31 +1,21 @@
|
||||
//js/sidebar.js
|
||||
|
||||
import { loadView } from "./viewManager.js";
|
||||
import { viewInitRegistry } from "./viewManager.js";
|
||||
// js/sidebar.js
|
||||
import { setHashView } from "./index.js"; // <--- or wherever you put it
|
||||
|
||||
export function setupSidebarNavigation() {
|
||||
// Grab all primary nav links that use the "#view=..." pattern
|
||||
const sidebarLinks = document.querySelectorAll('#sidebar a[href^="#view="]');
|
||||
sidebarLinks.forEach((link) => {
|
||||
link.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
// For a link like "#view=most-recent-videos", parse out "most-recent-videos"
|
||||
const href = link.getAttribute("href") || "";
|
||||
const viewMatch = href.match(/#view=(.+)/);
|
||||
if (!viewMatch || !viewMatch[1]) {
|
||||
return;
|
||||
}
|
||||
const viewName = viewMatch[1]; // e.g. "most-recent-videos"
|
||||
const viewUrl = `views/${viewName}.html`;
|
||||
|
||||
// Load the partial view
|
||||
loadView(viewUrl).then(() => {
|
||||
// If there's a post-load function for this view, call it
|
||||
const initFn = viewInitRegistry[viewName];
|
||||
if (typeof initFn === "function") {
|
||||
initFn();
|
||||
}
|
||||
});
|
||||
// e.g. "#view=about"
|
||||
const href = link.getAttribute("href") || "";
|
||||
const match = href.match(/^#view=(.+)/);
|
||||
if (!match) return;
|
||||
|
||||
const viewName = match[1]; // "about", "ipns", etc.
|
||||
setHashView(viewName);
|
||||
// That removes ?modal=, ?v=, sets #view=viewName,
|
||||
// and triggers handleHashChange() automatically
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user