Skip to content

Commit 6cb7928

Browse files
Fix javascript side
1 parent c5740d4 commit 6cb7928

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

EssentialCSharp.Web/Views/Shared/_Layout.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
@* Recursive vue component template for rendering the table of contents. *@
278278
<template id="toc-tree">
279279
<li v-if="item.items.length">
280-
<details :open="expandedTocs.has(item.key)"
280+
<details :open="expandedTocs.has(item.keys)"
281281
v-on:toggle="!$event.target.open ? expandedTocs.delete(item.key) : expandedTocs.add(item.key)">
282282
<summary :class="{
283283
'toc-content' : item.level==0,
@@ -312,7 +312,7 @@
312312
<a class="section-link" :class="{
313313
['indent-level-' + (item.level)]: true,
314314
'current-section' : currentPage.some(p=>
315-
p.key == item.key),
315+
JSON.stringify(p.keys) == JSON.stringify(item.keys)),
316316
}" :href="item.href"> {{item.title}}
317317
</a>
318318
</li>

EssentialCSharp.Web/wwwroot/js/site.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ const completedFeaturesList = [
8080
function findCurrentPage(path, items) {
8181
for (const item of items) {
8282
const itemPath = [item, ...path];
83-
if (
84-
window.location.href.endsWith("/" + item.href) ||
85-
window.location.href.endsWith("/" + item.key)
86-
) {
87-
return itemPath;
83+
if (window.location.href.endsWith("/" + item.href)) {
84+
return itemPath;
85+
}
86+
for (let key of item.keys) {
87+
if (window.location.href.endsWith("/" + item.key)) {
88+
return itemPath;
89+
}
8890
}
8991

9092
const recursivePath = findCurrentPage(itemPath, item.items);
@@ -199,7 +201,7 @@ const app = createApp({
199201
const sectionTitle = ref(currentPage?.[0]?.title || "Essential C#");
200202
const expandedTocs = reactive(new Set());
201203
for (const item of currentPage) {
202-
expandedTocs.add(item.key);
204+
expandedTocs.add(item.keys);
203205
}
204206

205207
// hide the sidebar when resizing to small screen
@@ -269,15 +271,15 @@ const app = createApp({
269271
expandedTocs.clear();
270272
// If a search query is removed, open the TOC for the current page.
271273
for (const item of currentPage) {
272-
expandedTocs.add(item.key);
274+
expandedTocs.add(item.keys);
273275
}
274276
}
275277
else {
276278
expandedTocs.clear();
277279
const query = normalizeString(newQuery);
278280
tocData.forEach(item => {
279281
if (filterItem(item, query)) {
280-
expandedTocs.add(item.key);
282+
expandedTocs.add(item.keys);
281283
}
282284
});
283285
}

0 commit comments

Comments
 (0)