Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 1708e26

Browse files
committed
feat: prev/next buttons for navigation
1 parent 7c28b98 commit 1708e26

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ The development server will be running at [http://localhost:3000](http://localho
4848
- [x] Search in command palette
4949
- [ ] Search button
5050
- [ ] Navigation
51-
- [ ] Dropdown for guide outlines
51+
- [x] Dropdown for guide outlines
5252
- [ ] Breadcrumbs
53-
- [ ] Previous/Next buttons
53+
- [x] Previous/Next buttons
5454
- [x] Embedded Nuxt Docs (update CORS headers)
5555
- [x] Only make necessary changes when navigating between guides
5656
- [x] Switch playgrounds on different guides

components/ContentNavCard.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
to: string
4+
icon?: string
5+
title: string
6+
subheader: string
7+
description: string
8+
}>()
9+
</script>
10+
11+
<template>
12+
<div
13+
flex="~ col"
14+
class="flex-1 p4"
15+
border="~ base rounded-lg hover:primary"
16+
relative block h-full
17+
>
18+
<span class="pointer-events-none mb4 h-7 w-7 inline-flex flex-none items-center text-lg text-primary" :class="icon" />
19+
<div class="my-0 text-lg font-semibold">
20+
{{ title }}
21+
</div>
22+
<div class="line-clamp line-clamp-2 mb-0 mt-1 text-[14px] op50">
23+
{{ description }}
24+
<slot />
25+
</div>
26+
<NuxtLink :to="to" class="absolute inset-0" />
27+
</div>
28+
</template>

components/PanelDocs.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ const sourceUrl = computed(() => page.value?._file
77
: undefined)
88
99
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation())
10+
11+
const {
12+
// // Global references
13+
// globals,
14+
// navigation,
15+
// surround,
16+
// page,
17+
// // Computed properties from `page` key
18+
// excerpt,
19+
// toc,
20+
// type,
21+
// layout,
22+
// Computed properties from `surround` key
23+
next,
24+
prev,
25+
} = useContent()
1026
</script>
1127

1228
<template>
@@ -25,6 +41,29 @@ const { data: navigation } = await useAsyncData('navigation', () => fetchContent
2541
<div relative h-full of-hidden>
2642
<article class="max-w-none prose" h-full of-auto p6>
2743
<ContentDoc />
44+
<div mt8 py2 grid="~ cols-[1fr_1fr] gap-4">
45+
<div>
46+
<ContentNavCard
47+
v-if="prev"
48+
:to="prev._path"
49+
:title="prev.title"
50+
:description="prev.description"
51+
subheader="Previous section"
52+
icon="i-ph-arrow-left"
53+
/>
54+
</div>
55+
<div>
56+
<ContentNavCard
57+
v-if="next"
58+
:to="next._path"
59+
:title="next.title"
60+
:description="next.description"
61+
subheader="Next section"
62+
icon="i-ph-arrow-right"
63+
items-end text-right
64+
/>
65+
</div>
66+
</div>
2867
</article>
2968
<!-- Navigration Dropdown -->
3069
<div

0 commit comments

Comments
 (0)