Skip to content

Commit 8c22216

Browse files
authored
chore: update the playground styling to be easier to navigate (#3270)
1 parent 59d1e82 commit 8c22216

File tree

13 files changed

+261
-211
lines changed

13 files changed

+261
-211
lines changed

playground/app.vue

+70-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,77 @@
11
<script setup lang="ts">
2+
const items = ref([
3+
{
4+
label: 'Default',
5+
icon: 'i-lucide-book-open',
6+
to: '/',
7+
children: [
8+
{
9+
label: 'Playground',
10+
to: '/playground',
11+
},
12+
{
13+
label: 'Query Playground',
14+
to: '/query-playground',
15+
},
16+
],
17+
},
18+
{
19+
label: 'Vue',
20+
icon: 'i-logos-vue',
21+
to: '/vue',
22+
},
23+
{
24+
label: 'Nuxt',
25+
icon: 'i-logos-nuxt-icon',
26+
to: '/nuxt/getting-started/introduction',
27+
},
28+
{
29+
label: 'Hacker News',
30+
icon: 'i-ion-logo-hackernews',
31+
to: '/hackernews',
32+
},
33+
{
34+
label: 'Content V2',
35+
icon: 'i-lucide-folder-open',
36+
to: '/content-v2',
37+
},
38+
{
39+
label: 'Data',
40+
icon: 'i-lucide-folder-open',
41+
to: '/data',
42+
},
43+
])
244
</script>
345

446
<template>
5-
<NuxtLayout>
6-
<NuxtPage />
7-
</NuxtLayout>
47+
<UApp>
48+
<UHeader title="Nuxt Content: Playground">
49+
<UNavigationMenu
50+
:items="items"
51+
class="w-full justify-center"
52+
/>
53+
54+
<template #body>
55+
<UNavigationMenu
56+
:items="items"
57+
orientation="vertical"
58+
class="-mx-2.5"
59+
/>
60+
</template>
61+
62+
<template #right>
63+
<UColorModeButton />
64+
</template>
65+
</UHeader>
66+
67+
<UMain>
68+
<UContainer>
69+
<NuxtLayout>
70+
<NuxtPage />
71+
</NuxtLayout>
72+
</UContainer>
73+
</UMain>
74+
</UApp>
875
</template>
976

1077
<style>

playground/components/ContentPage.vue

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<script setup lang="ts">
2+
import type { ContentNavigationItem } from '@nuxt/content'
3+
4+
interface TocLink {
5+
id: string
6+
depth: number
7+
text: string
8+
children?: TocLink[]
9+
}
10+
11+
interface ContentData {
12+
title?: string
13+
description?: string
14+
body?: {
15+
toc?: {
16+
links?: TocLink[]
17+
}
18+
}
19+
}
20+
21+
interface Props {
22+
data: ContentData | null
23+
navigation?: ContentNavigationItem[] | null
24+
surround?: ContentNavigationItem[] | null
25+
}
26+
27+
const props = withDefaults(defineProps<Props>(), {
28+
navigation: () => [],
29+
surround: undefined,
30+
})
31+
32+
const bodyTocLinksWithDebug = computed(() => {
33+
return [
34+
...props.data.body.toc.links,
35+
{
36+
id: 'debug-nuxt-content',
37+
depth: 0,
38+
text: '🐞 Debug',
39+
},
40+
]
41+
})
42+
</script>
43+
44+
<template>
45+
<UPage v-if="data">
46+
<template #left>
47+
<UPageAside>
48+
<UContentNavigation
49+
v-if="navigation?.length"
50+
:navigation="navigation"
51+
/>
52+
</UPageAside>
53+
</template>
54+
55+
<template #right>
56+
<UContentToc
57+
v-if="data?.body?.toc?.links"
58+
:links="bodyTocLinksWithDebug"
59+
/>
60+
</template>
61+
62+
<UPageHeader
63+
:title="data.title"
64+
:description="data.description"
65+
/>
66+
67+
<UPageBody>
68+
<ContentRenderer
69+
:value="data"
70+
>
71+
<template #empty>
72+
<div>
73+
<h1>No Content Available</h1>
74+
</div>
75+
</template>
76+
</ContentRenderer>
77+
78+
<template v-if="surround">
79+
<USeparator />
80+
<UContentSurround :surround="surround" />
81+
</template>
82+
83+
<UCard>
84+
<template #header>
85+
<h3
86+
id="debug-nuxt-content"
87+
class="text-lg font-semibold mb-2"
88+
>
89+
Debug
90+
</h3>
91+
</template>
92+
93+
<UTabs
94+
variant="link"
95+
:items="[
96+
{ label: 'Content', content: data as string },
97+
{ label: 'Surround', content: surround as unknown as string },
98+
{ label: 'Navigation', content: navigation as unknown as string },
99+
{ label: 'Content Toc', content: data?.body?.toc?.links as unknown as string },
100+
]"
101+
>
102+
<template #content="{ item }">
103+
<ProsePre class="overflow-auto max-h-[300px] text-xs">
104+
{{ item }}
105+
</ProsePre>
106+
</template>
107+
</UTabs>
108+
</UCard>
109+
</UPageBody>
110+
</UPage>
111+
</template>

playground/layouts/content-v2.vue

-29
This file was deleted.

playground/layouts/default.vue

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
<script setup lang="ts">
2-
const { data } = await useAsyncData('contents-list', () => queryCollectionNavigation('content'))
3-
const links = computed(() => {
4-
return data.value?.map(item => ({
5-
label: item.title,
6-
to: item.page !== false ? item.path : undefined,
7-
children: (item.children?.map(child => ({
8-
label: child.title,
9-
to: child.path,
10-
})) ?? []),
11-
}))
12-
})
13-
</script>
14-
151
<template>
16-
<div class="flex">
17-
<UNavigationMenu
18-
class="w-[200px] flex-none p-2 sticky top-0 h-screen"
19-
orientation="vertical"
20-
:items="links"
21-
/>
22-
<div class="flex-1 p-4 prose prose-invert">
23-
<slot />
24-
</div>
2+
<div>
3+
<slot />
254
</div>
265
</template>

playground/layouts/empty.vue

-5
This file was deleted.

playground/layouts/nuxt.vue

-26
This file was deleted.

playground/layouts/vue.vue

-29
This file was deleted.

playground/pages/[...slug].vue

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
const route = useRoute()
33
4+
const { data: navigation } = await useAsyncData('contents-list', () => queryCollectionNavigation('content'))
45
const { data } = await useAsyncData('posts' + route.path, async () => {
56
return await queryCollection('content').path(route.path).first()
67
})
@@ -12,26 +13,12 @@ const { data: surround } = await useAsyncData('content-surround' + route.path, (
1213
fields: ['title', 'description'],
1314
})
1415
})
15-
16-
definePageMeta({
17-
layout: 'default',
18-
layoutTransition: false,
19-
})
2016
</script>
2117

2218
<template>
23-
<div class="content-page">
24-
<ContentRenderer
25-
v-if="data"
26-
:value="data"
27-
>
28-
<template #empty>
29-
<div>
30-
<h1>Nobody Exists</h1>
31-
</div>
32-
</template>
33-
</ContentRenderer>
34-
<h2>Surround</h2>
35-
<pre>{{ surround }}</pre>
36-
</div>
19+
<ContentPage
20+
:data="data"
21+
:navigation="navigation"
22+
:surround="surround"
23+
/>
3724
</template>

0 commit comments

Comments
 (0)