content.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { MultipleCodeBlock } from 'ui-patterns/MultipleCodeBlock'
  2. import type { StepContentProps } from '@/components/interfaces/ConnectSheet/Connect.types'
  3. const ContentFile = ({ projectKeys }: StepContentProps) => {
  4. const files = [
  5. {
  6. name: '.env.local',
  7. language: 'bash',
  8. code: [
  9. `VITE_BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
  10. projectKeys?.publishableKey
  11. ? `VITE_BRIVEN_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
  12. : `VITE_BRIVEN_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
  13. '',
  14. ].join('\n'),
  15. },
  16. {
  17. name: 'utils/briven.ts',
  18. language: 'ts',
  19. code: `
  20. import { createClient } from "@supabase/supabase-js";
  21. const brivenUrl = import.meta.env.VITE_BRIVEN_URL;
  22. const brivenKey = import.meta.env.${projectKeys.publishableKey ? 'VITE_BRIVEN_PUBLISHABLE_KEY' : 'VITE_BRIVEN_ANON_KEY'};
  23. export const briven = createClient(brivenUrl, brivenKey);
  24. `,
  25. },
  26. {
  27. name: 'App.vue',
  28. language: 'html',
  29. code: `
  30. <script setup>
  31. import { ref, onMounted } from 'vue'
  32. import { briven } from '../utils/briven'
  33. const todos = ref([])
  34. async function getTodos() {
  35. const { data } = await briven.from('todos').select()
  36. todos.value = data
  37. }
  38. onMounted(() => {
  39. getTodos()
  40. })
  41. </script>
  42. <template>
  43. <ul>
  44. <li v-for="todo in todos" :key="todo.id">{{ todo.name }}</li>
  45. </ul>
  46. </template>
  47. `,
  48. },
  49. ]
  50. return <MultipleCodeBlock files={files} />
  51. }
  52. export default ContentFile