added better markdown view pages and enabled subscription button to know when your logged in

This commit is contained in:
Keep Creating Online
2025-02-06 15:15:29 -05:00
parent 6cf1d53624
commit 7e661ba0fd
24 changed files with 487 additions and 3240 deletions

View File

@@ -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
});
});
}