content.tsx65 lines · main
1import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
2
3import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
4
5const ContentFile = ({ projectKeys }: StepContentProps) => {
6 const files = [
7 {
8 name: '.env.local',
9 language: 'bash',
10 code: [
11 `BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
12 `BRIVEN_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}`,
13 '',
14 ].join('\n'),
15 },
16 {
17 name: 'nuxt.config.ts',
18 language: 'ts',
19 code: `
20export default defineNuxtConfig({
21 runtimeConfig: {
22 public: {
23 brivenUrl: process.env.BRIVEN_URL,
24 brivenKey: process.env.BRIVEN_KEY,
25 },
26 },
27})
28`,
29 },
30 {
31 name: 'app.vue',
32 language: 'html',
33 code: `
34<script setup>
35import { ref, onMounted } from 'vue'
36import { createClient } from '@supabase/supabase-js'
37
38const config = useRuntimeConfig()
39const briven = createClient(config.public.brivenUrl, config.public.brivenKey)
40
41const todos = ref([])
42
43async function getTodos() {
44 const { data } = await briven.from('todos').select()
45 todos.value = data
46}
47
48onMounted(() => {
49 getTodos()
50})
51</script>
52
53<template>
54 <ul>
55 <li v-for="todo in todos" :key="todo.id">{{ todo.name }}</li>
56 </ul>
57</template>
58`,
59 },
60 ]
61
62 return <MultipleCodeBlock files={files} />
63}
64
65export default ContentFile