Skip to content

Commit cafc5aa

Browse files
Revert "Add helper method + more key => keys fixes"
This reverts commit 1fb2ffb. Revert "Change stringify implementation" This reverts commit 98f4423. Redo buried changes for key => keys
1 parent d55c821 commit cafc5aa

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

EssentialCSharp.Web/Views/Shared/_Layout.cshtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200

201201
<div v-cloak v-if="sidebarTab == 'toc'" class="toc-tree" id="toc">
202202
<ul class="tree">
203-
<toc-tree v-for="item in filteredTocData" :item="item" :expanded-tocs="expandedTocs" :current-page="currentPage" :first-or-default="firstOrDefault"></toc-tree>
203+
<toc-tree v-for="item in filteredTocData" :item="item" :expanded-tocs="expandedTocs" :current-page="currentPage"></toc-tree>
204204
</ul>
205205
</div>
206206
<div v-cloak>
@@ -283,36 +283,36 @@
283283
'toc-content' : item.level==0,
284284
'nested' : item.level>
285285
0,
286-
'current-section': currentPage.some(p => firstOrDefault(p.keys) == firstOrDefault(item.keys)),
286+
'current-section': currentPage.some(p => JSON.stringify(p.keys) == JSON.stringify(item.keys)),
287287
}" :href="item.href">{{item.title}}
288288
</summary>
289289
<ul>
290290
<li :class="{
291291
['indent-level-' + (item.level+1)]: true,
292292
'current-li' : currentPage.some(p=>
293-
firstOrDefault(p.keys) == firstOrDefault(item.keys)) && !currentPage.some(p => p.level > item.level),
293+
JSON.stringify(p.keys) == JSON.stringify(item.keys)) && !currentPage.some(p => p.level > item.level),
294294
}" >
295295
<a class="section-link" :class="{
296296
['indent-level-' + (item.level+1)]: true,
297297
'current-section' : currentPage.some(p=>
298-
firstOrDefault(p.keys) == firstOrDefault(item.keys)) && !currentPage.some(p => p.level > item.level),
298+
JSON.stringify(p.keys) == JSON.stringify(item.keys)) && !currentPage.some(p => p.level > item.level),
299299
}" :href="item.href"> Introduction
300300
</a>
301301
</li>
302-
<toc-tree v-for="childItem in item.items" :item="childItem" :expanded-tocs="expandedTocs" :current-page="currentPage" :first-or-default="firstOrDefault"></toc-tree>
302+
<toc-tree v-for="childItem in item.items" :item="childItem" :expanded-tocs="expandedTocs" :current-page="currentPage"></toc-tree>
303303
</ul>
304304
<hr class="divider" v-if="item.level === 0" />
305305
</details>
306306
</li>
307307
<li v-else :class="{
308308
['indent-level-' + (item.level+1)]: true,
309309
'current-li' : currentPage.some(p=>
310-
firstOrDefault(p.keys) == firstOrDefault(item.keys)) && !currentPage.some(p => p.level > item.level),
310+
JSON.stringify(p.keys) == JSON.stringify(item.keys)) && !currentPage.some(p => p.level > item.level),
311311
}" >
312312
<a class="section-link" :class="{
313313
['indent-level-' + (item.level)]: true,
314314
'current-section' : currentPage.some(p=>
315-
firstOrDefault(p.keys) == firstOrDefault(item.keys)),
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: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,6 @@ const app = createApp({
187187

188188
const sidebarShown = ref(false);
189189

190-
/**
191-
* Find the first element of a list, otherwise null
192-
* @param {string[]} list
193-
* @returns {string | undefined} first element or null
194-
* */
195-
function firstOrDefault(list) {
196-
if (list.length > 0) {
197-
return list[0];
198-
}
199-
return undefined;
200-
}
201-
202190
const smallScreen = computed(() => {
203191
return (windowWidth.value || 0) < smallScreenSize;
204192
});
@@ -318,7 +306,6 @@ const app = createApp({
318306

319307
sidebarShown,
320308
sidebarTab,
321-
firstOrDefault,
322309

323310
smallScreen,
324311

@@ -336,7 +323,7 @@ const app = createApp({
336323
});
337324

338325
app.component("toc-tree", {
339-
props: ["item", "expandedTocs", "currentPage", "firstOrDefault"],
326+
props: ["item", "expandedTocs", "currentPage"],
340327
template: "#toc-tree",
341328
});
342329

0 commit comments

Comments
 (0)