Skip to content

Commit 2e4b9c1

Browse files
committed
docs: initial docs setup
1 parent 59b84ab commit 2e4b9c1

32 files changed

+11130
-1
lines changed

docs/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Production license for @nuxt/ui-pro, get one at https://ui.nuxt.com/pro/purchase
2+
NUXT_UI_PRO_LICENSE=
3+
4+
# Public URL, used for OG Image when running nuxt generate
5+
NUXT_PUBLIC_SITE_URL=

docs/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Nuxt dev/build outputs
2+
.output
3+
.data
4+
.nuxt
5+
.nitro
6+
.cache
7+
dist
8+
9+
# Node dependencies
10+
node_modules
11+
12+
# Logs
13+
logs
14+
*.log
15+
16+
# Misc
17+
.DS_Store
18+
.fleet
19+
.idea
20+
21+
# Local env files
22+
.env
23+
.env.*
24+
!.env.example
25+
26+
# VSC
27+
.history

docs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

docs/app.config.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
export default defineAppConfig({
2+
ui: {
3+
primary: 'blue',
4+
gray: 'slate',
5+
footer: {
6+
bottom: {
7+
left: 'text-sm text-gray-500 dark:text-gray-400',
8+
wrapper: 'border-t border-gray-200 dark:border-gray-800',
9+
},
10+
},
11+
},
12+
seo: {
13+
siteName: 'tRPC Vue-Query',
14+
},
15+
header: {
16+
logo: {
17+
alt: '',
18+
light: '',
19+
dark: '',
20+
},
21+
search: true,
22+
colorMode: true,
23+
links: [
24+
{
25+
'icon': 'i-simple-icons-github',
26+
'to': 'https://github.com/falcondev-oss/trpc-vue-query',
27+
'target': '_blank',
28+
'aria-label': 'tRPC Vue-Query on GitHub',
29+
},
30+
],
31+
},
32+
footer: {
33+
credits: 'Copyright © 2024',
34+
colorMode: false,
35+
links: [
36+
{
37+
'icon': 'i-simple-icons-github',
38+
'to': 'https://github.com/falcondev-oss/trpc-vue-query',
39+
'target': '_blank',
40+
'aria-label': 'tRPC Vue-Query on GitHub',
41+
},
42+
],
43+
},
44+
toc: {
45+
title: 'Table of Contents',
46+
bottom: {
47+
title: 'Community',
48+
links: [
49+
{
50+
icon: 'i-heroicons-star',
51+
label: 'Star on GitHub',
52+
to: 'https://github.com/falcondev-oss/trpc-vue-query',
53+
target: '_blank',
54+
},
55+
],
56+
},
57+
},
58+
})

docs/app.vue

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script setup lang="ts">
2+
import type { ParsedContent } from '@nuxt/content/dist/runtime/types'
3+
4+
const { seo } = useAppConfig()
5+
6+
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation())
7+
const { data: files } = useLazyFetch<ParsedContent[]>('/api/search.json', {
8+
default: () => [],
9+
server: false,
10+
})
11+
12+
useHead({
13+
meta: [{ name: 'viewport', content: 'width=device-width, initial-scale=1' }],
14+
link: [{ rel: 'icon', href: '/favicon.ico' }],
15+
htmlAttrs: {
16+
lang: 'en',
17+
},
18+
})
19+
20+
useSeoMeta({
21+
titleTemplate: `%s - ${seo?.siteName}`,
22+
ogSiteName: seo?.siteName,
23+
})
24+
25+
provide('navigation', navigation)
26+
</script>
27+
28+
<template>
29+
<div>
30+
<NuxtLoadingIndicator />
31+
32+
<Header />
33+
34+
<UMain>
35+
<NuxtLayout>
36+
<NuxtPage />
37+
</NuxtLayout>
38+
</UMain>
39+
40+
<Footer />
41+
42+
<ClientOnly>
43+
<LazyUContentSearch :files="files" :navigation="navigation" />
44+
</ClientOnly>
45+
46+
<UNotifications />
47+
</div>
48+
</template>

docs/components/Footer.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<script setup lang="ts">
2+
const { footer } = useAppConfig()
3+
</script>
4+
5+
<template>
6+
<UFooter>
7+
<template #left>
8+
{{ footer.credits }}
9+
</template>
10+
11+
<template #right>
12+
<UColorModeButton v-if="footer?.colorMode" />
13+
14+
<template v-if="footer?.links">
15+
<UButton
16+
v-for="(link, index) of footer?.links"
17+
:key="index"
18+
v-bind="{ color: 'gray', variant: 'ghost', ...link }"
19+
/>
20+
</template>
21+
</template>
22+
</UFooter>
23+
</template>

docs/components/Header.vue

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<script setup lang="ts">
2+
import type { NavItem } from '@nuxt/content/dist/runtime/types'
3+
4+
const navigation = inject<NavItem[]>('navigation', [])
5+
6+
const { header } = useAppConfig()
7+
</script>
8+
9+
<template>
10+
<UHeader>
11+
<template #logo>
12+
<template v-if="header?.logo?.dark || header?.logo?.light">
13+
<UColorModeImage v-bind="{ class: 'h-6 w-auto', ...header?.logo }" />
14+
</template>
15+
<template v-else>
16+
tRPC Vue-Query
17+
<UBadge label="Docs" variant="subtle" class="mb-0.5" />
18+
</template>
19+
</template>
20+
21+
<template v-if="header?.search" #center>
22+
<UContentSearchButton class="hidden lg:flex" />
23+
</template>
24+
25+
<template #right>
26+
<UContentSearchButton v-if="header?.search" :label="null" class="lg:hidden" />
27+
28+
<UColorModeButton v-if="header?.colorMode" />
29+
30+
<template v-if="header?.links">
31+
<UButton
32+
v-for="(link, index) of header.links"
33+
:key="index"
34+
v-bind="{ color: 'gray', variant: 'ghost', ...link }"
35+
/>
36+
</template>
37+
</template>
38+
39+
<template #panel>
40+
<UNavigationTree :links="mapContentNavigation(navigation)" />
41+
</template>
42+
</UHeader>
43+
</template>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script lang="ts" setup>
2+
defineOptions({
3+
inheritAttrs: false,
4+
})
5+
6+
defineProps({
7+
title: {
8+
type: String,
9+
required: true,
10+
},
11+
description: {
12+
type: String,
13+
required: true,
14+
},
15+
})
16+
</script>
17+
18+
<template>
19+
<div class="flex h-full w-full flex-col justify-center bg-slate-900 p-8 text-center">
20+
<div class="relative">
21+
<h1 class="mb-4 text-8xl text-white">
22+
{{ title }}
23+
</h1>
24+
<p class="text-5xl leading-tight text-gray-200">
25+
{{ description }}
26+
</p>
27+
</div>
28+
</div>
29+
</template>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: Getting Started
3+
description: Install and setup tRPC Vue-Query
4+
---
5+
6+
## Install
7+
8+
::code-group
9+
10+
```bash [pnpm]
11+
pnpm add @falcondev-oss/trpc-vue-query
12+
```
13+
14+
```bash [yarn]
15+
yarn add @falcondev-oss/trpc-vue-query
16+
```
17+
18+
```bash [bun]
19+
bun add @falcondev-oss/trpc-vue-query
20+
```
21+
22+
```bash [npm]
23+
npm install @falcondev-oss/trpc-vue-query
24+
```
25+
26+
::
27+
28+
## Setup with Vue 3
29+
30+
```ts [main.ts]
31+
import { createTRPCVueQueryClient } from '@falcondev-oss/trpc-vue-query'
32+
import type { AppRouter } from '../your_server/trpc'
33+
import { VueQueryPlugin, useQueryClient } from '@tanstack/vue-query'
34+
35+
app.use(VueQueryPlugin)
36+
app.use({
37+
install(app) {
38+
const queryClient = app.runWithContext(useQueryClient)
39+
const trpc = createTRPCVueQueryClient<AppRouter>({
40+
queryClient,
41+
trpc: {
42+
links: [
43+
httpBatchLink({
44+
url: '/api/trpc',
45+
}),
46+
],
47+
},
48+
})
49+
50+
app.provide('trpc', trpc)
51+
},
52+
})
53+
```
54+
55+
```ts [composables/useTRPC.ts]
56+
import { createTRPCVueQueryClient } from '@falcondev-oss/trpc-vue-query'
57+
import type { AppRouter } from '../your_server/trpc'
58+
59+
export function useTRPC() {
60+
return inject('trpc') as ReturnType<typeof createTRPCVueQueryClient<AppRouter>>
61+
}
62+
```
63+
64+
## Setup with Nuxt 3
65+
66+
Setup `trpc-nuxt` as described in their [documentation](https://trpc-nuxt.vercel.app/get-started/usage/recommended). Then update the `plugins/client.ts` file:
67+
68+
```ts [plugins/client.ts]
69+
import { createTRPCVueQueryClient } from '@falcondev-oss/trpc-vue-query'
70+
import { useQueryClient } from '@tanstack/vue-query'
71+
import { httpBatchLink } from 'trpc-nuxt/client'
72+
import type { AppRouter } from '~/server/trpc/routers'
73+
74+
export default defineNuxtPlugin(() => {
75+
const queryClient = useQueryClient()
76+
77+
// ⬇️ use `createTRPCVueQueryClient` instead of `createTRPCNuxtClient` ⬇️
78+
const trpc = createTRPCVueQueryClient<AppRouter>({
79+
queryClient,
80+
trpc: {
81+
links: [
82+
httpBatchLink({
83+
url: '/api/trpc',
84+
}),
85+
],
86+
},
87+
})
88+
89+
return {
90+
provide: {
91+
trpc,
92+
},
93+
}
94+
})
95+
```
96+
97+
```ts [composables/useTRPC.ts]
98+
export function useTRPC() {
99+
return useNuxtApp().$trpc
100+
}
101+
```
102+
103+
## Acknowledgements
104+
105+
Huge thanks to [Robert Soriano](https://github.com/wobsoriano) for creating `nuxt-trpc`! We just adapted his work to work with Vue Query.

0 commit comments

Comments
 (0)