Skip to content

Commit 5b78288

Browse files
committed
fix: fixes sorting for outline items
1 parent f208ee5 commit 5b78288

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

docs/.vuepress/components/outline.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
2828
const sortedCategories = ['frontend', 'tools', 'backend', 'other'];
2929
30+
function getCategoryIndex(skill) {
31+
return sortedCategories.indexOf(skill.catagory);
32+
}
33+
34+
function equalsCategory(skill, other) {
35+
return getCategoryIndex(skill) === getCategoryIndex(other);
36+
}
37+
3038
export default {
3139
name: 'outline',
3240
props: ['outline'],
@@ -35,11 +43,12 @@ export default {
3543
if (!this.outline.skills) {
3644
return [];
3745
}
46+
3847
return this.outline.skills.sort((skill, other) => {
39-
if (sortedCategories.indexOf(skill.catagory) !== sortedCategories.indexOf(other.catagory)) {
40-
return sortedCategories.indexOf(skill.catagory) - sortedCategories.indexOf(skill.catagory);
48+
if (equalsCategory(skill, other)) {
49+
return getCategoryIndex(other) - getCategoryIndex(skill);
4150
}
42-
other.level - skill.level;
51+
return other.level - skill.level;
4352
});
4453
}
4554
}

docs/.vuepress/theme/Layout.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
<script>
5555
export default {
5656
data() {
57-
console.log('+++ data', Number.POSITIVE_INFINITY);
58-
5957
return {
6058
tableOfContents: false,
6159
@@ -67,7 +65,6 @@ export default {
6765
},
6866
methods: {
6967
setTableOfContents(value) {
70-
console.log('+++ value', value);
7168
this.tableOfContents = value;
7269
},
7370
},
@@ -301,7 +298,7 @@ export default {
301298
}
302299
}
303300
304-
p {
301+
p, ul {
305302
margin-bottom: 0.5rem;
306303
}
307304

0 commit comments

Comments
 (0)