Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vitepress/theme/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import DefaultTheme from 'vitepress/theme'
import AsideSpecs from './components/AsideSpecs.vue'
import ChildPages from './components/ChildPages.vue'
import NotFound from './components/NotFound.vue'
import PageHeader from './components/PageHeader.vue'
import SiteFooter from './components/SiteFooter.vue'
Expand All @@ -15,6 +16,7 @@ import SiteFooter from './components/SiteFooter.vue'
<AsideSpecs />
</template>
<template #doc-after>
<ChildPages />
<SiteFooter />
</template>
<template #not-found>
Expand Down
42 changes: 42 additions & 0 deletions .vitepress/theme/components/ChildPages.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { useData, withBase, type DefaultTheme } from 'vitepress'
import { computed } from 'vue'

/**
* "Table of contents" of the pages with `has_children` (as Just the Docs did): the child pages,
* taken from the sidebar so they have the same order and the same `nav_exclude`.
*/
const { page, theme } = useData()

function find(items: DefaultTheme.SidebarItem[], url: string): DefaultTheme.SidebarItem | undefined {
for (const item of items) {
if (item.link === url) return item
const found = item.items && find(item.items, url)
if (found) return found
}
}

const children = computed(() => {
if (!page.value.frontmatter.has_children) return []
const url = '/' + page.value.relativePath.replace(/(^|\/)index\.md$/, '$1')
const sidebar = theme.value.sidebar as DefaultTheme.SidebarItem[]
return find(sidebar, url)?.items ?? []
})
</script>

<template>
<nav v-if="children.length" class="child-pages vp-doc" aria-labelledby="child-pages-title">
<h2 id="child-pages-title">Table of contents</h2>
<ul>
<li v-for="child in children" :key="child.link">
<a :href="withBase(child.link!)">{{ child.text }}</a>
</li>
</ul>
</nav>
</template>

<style scoped>
.child-pages {
margin-top: 32px;
}
</style>
2 changes: 2 additions & 0 deletions ont-xgs/ont-comtrend-grg-4362.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ has_children: true
parent: Comtrend
---

# Hardware Specifications

| | |
| --------------- | -------------------------------------------------------------------------- |
| Vendor/Brand | Comtrend |
Expand Down
2 changes: 2 additions & 0 deletions ont/ont-comtrend-grg-4284.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ has_children: false
parent: Comtrend
---

# Hardware Specifications

| | |
| --------------- | -------------------------------------------------------------------------- |
| Vendor/Brand | Comtrend |
Expand Down
2 changes: 2 additions & 0 deletions ont/ont-tenda-hg1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ has_children: true
parent: Tenda
---

# Hardware Specifications

| | |
| --------------- | -------------------------------------------------------------------------- |
| Vendor/Brand | Tenda |
Expand Down
Loading