mirror of
https://github.com/pterodactyl/documentation.git
synced 2025-12-10 00:09:39 -06:00
fix errors by components getting reused improperly
This commit is contained in:
parent
060305f6c8
commit
b520343189
@ -1,70 +1,72 @@
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<NavLinks class="block md:hidden"/>
|
||||
<slot name="top"/>
|
||||
<ul class="sidebar-links" v-if="items.length">
|
||||
<li v-for="(item, i) in items" :key="i">
|
||||
<SidebarGroup v-if="item.type === 'group'"
|
||||
:item="item"
|
||||
:first="i === 0"
|
||||
:open="i === openGroupIndex"
|
||||
:collapsable="item.collapsable"
|
||||
@toggle="toggleGroup(i)"/>
|
||||
<SidebarLink v-else :item="item"/>
|
||||
</li>
|
||||
</ul>
|
||||
<slot name="bottom"/>
|
||||
</div>
|
||||
<div class="sidebar">
|
||||
<NavLinks class="block md:hidden" />
|
||||
<slot name="top" />
|
||||
<ul class="sidebar-links" v-if="items.length">
|
||||
<li v-for="(item, i) in items" :key="item.path">
|
||||
<SidebarGroup
|
||||
v-if="item.type === 'group'"
|
||||
:item="item"
|
||||
:first="i === 0"
|
||||
:open="i === openGroupIndex"
|
||||
:collapsable="item.collapsable"
|
||||
@toggle="toggleGroup(i)"
|
||||
/>
|
||||
<SidebarLink v-else :item="item" />
|
||||
</li>
|
||||
</ul>
|
||||
<slot name="bottom" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SidebarGroup from './SidebarGroup.vue';
|
||||
import SidebarLink from './SidebarLink.vue';
|
||||
import NavLinks from './NavLinks.vue';
|
||||
import { isActive } from './util';
|
||||
import SidebarGroup from "./SidebarGroup.vue";
|
||||
import SidebarLink from "./SidebarLink.vue";
|
||||
import NavLinks from "./NavLinks.vue";
|
||||
import { isActive } from "./util";
|
||||
|
||||
export default {
|
||||
components: { SidebarGroup, SidebarLink, NavLinks },
|
||||
props: ['items'],
|
||||
data() {
|
||||
return {
|
||||
openGroupIndex: 0
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.refreshIndex();
|
||||
},
|
||||
watch: {
|
||||
'$route'() {
|
||||
this.refreshIndex();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
refreshIndex() {
|
||||
const index = resolveOpenGroupIndex(
|
||||
this.$route,
|
||||
this.items
|
||||
);
|
||||
if (index > - 1) {
|
||||
this.openGroupIndex = index;
|
||||
}
|
||||
},
|
||||
toggleGroup(index) {
|
||||
this.openGroupIndex = index === this.openGroupIndex ? - 1 : index;
|
||||
},
|
||||
isActive(page) {
|
||||
return isActive(this.$route, page.path);
|
||||
}
|
||||
}
|
||||
export default {
|
||||
components: { SidebarGroup, SidebarLink, NavLinks },
|
||||
props: ["items"],
|
||||
data() {
|
||||
return {
|
||||
openGroupIndex: 0
|
||||
};
|
||||
|
||||
function resolveOpenGroupIndex(route, items) {
|
||||
for (let i = 0; i < items.length; i ++) {
|
||||
const item = items[i];
|
||||
if (item.type === 'group' && item.children.some(c => isActive(route, c.path))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return - 1;
|
||||
},
|
||||
created() {
|
||||
this.refreshIndex();
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.refreshIndex();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
refreshIndex() {
|
||||
const index = resolveOpenGroupIndex(this.$route, this.items);
|
||||
if (index > -1) {
|
||||
this.openGroupIndex = index;
|
||||
}
|
||||
},
|
||||
toggleGroup(index) {
|
||||
this.openGroupIndex = index === this.openGroupIndex ? -1 : index;
|
||||
},
|
||||
isActive(page) {
|
||||
return isActive(this.$route, page.path);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function resolveOpenGroupIndex(route, items) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (
|
||||
item.type === "group" &&
|
||||
item.children.some(c => isActive(route, c.path))
|
||||
) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -217,7 +217,6 @@ function resolveItem(item, pages, base, isNested) {
|
||||
status: version.name === item.currentVersion ? "current" : version.status,
|
||||
children: version.children.map(child => resolveItem(item.path + version.name + child, pages, base, true))
|
||||
})),
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user