fix navigation
This commit is contained in:
parent
f7cfb52504
commit
f8ca16a50d
|
@ -125,12 +125,15 @@ function expandDetailsRecursively(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigateToPage(page) {
|
function navigateToPage(page) {
|
||||||
window.location.href = `${TREEHOUSE_SITE}/${page}.html`
|
console.log(page);
|
||||||
|
window.location.pathname = `${TREEHOUSE_SITE}/${page}.html`
|
||||||
}
|
}
|
||||||
|
|
||||||
async function navigateToBranch(fragment) {
|
async function navigateToBranch(fragment) {
|
||||||
if (fragment.length == 0) return;
|
if (fragment.length == 0) return;
|
||||||
|
|
||||||
|
console.log(`nagivating to branch: ${fragment}`);
|
||||||
|
|
||||||
let element = document.getElementById(fragment);
|
let element = document.getElementById(fragment);
|
||||||
if (element !== null) {
|
if (element !== null) {
|
||||||
// If the element is already loaded on the page, we're good.
|
// If the element is already loaded on the page, we're good.
|
||||||
|
@ -138,6 +141,7 @@ async function navigateToBranch(fragment) {
|
||||||
rehash();
|
rehash();
|
||||||
} else {
|
} else {
|
||||||
// The element is not loaded, we need to load the tree that has it.
|
// The element is not loaded, we need to load the tree that has it.
|
||||||
|
console.log("element is not loaded");
|
||||||
let parts = fragment.split(':');
|
let parts = fragment.split(':');
|
||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
let [page, _id] = parts;
|
let [page, _id] = parts;
|
||||||
|
@ -147,8 +151,12 @@ async function navigateToBranch(fragment) {
|
||||||
// navigation maps with roots other than index. Currently though only index is
|
// navigation maps with roots other than index. Currently though only index is
|
||||||
// generated so that doesn't matter.
|
// generated so that doesn't matter.
|
||||||
let [_root, ...path] = fullPath;
|
let [_root, ...path] = fullPath;
|
||||||
|
console.log(`_root: ${_root}, path: ${path}`)
|
||||||
if (path !== undefined) {
|
if (path !== undefined) {
|
||||||
let isNotAtIndexHtml = window.location.pathname != "/index.html";
|
let isNotAtIndexHtml =
|
||||||
|
window.location.pathname != "" &&
|
||||||
|
window.location.pathname != "/" &&
|
||||||
|
window.location.pathname != "/index.html";
|
||||||
let lastBranch = null;
|
let lastBranch = null;
|
||||||
for (let linked of path) {
|
for (let linked of path) {
|
||||||
let branch = LinkedBranch.byLink.get(linked);
|
let branch = LinkedBranch.byLink.get(linked);
|
||||||
|
|
Loading…
Reference in a new issue