content.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. `BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
  10. `BRIVEN_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'}`,
  11. '',
  12. ].join('\n'),
  13. },
  14. {
  15. name: 'nuxt.config.ts',
  16. language: 'ts',
  17. code: `
  18. export default defineNuxtConfig({
  19. runtimeConfig: {
  20. public: {
  21. brivenUrl: process.env.BRIVEN_URL,
  22. brivenKey: process.env.BRIVEN_KEY,
  23. },
  24. },
  25. })
  26. `,
  27. },
  28. {
  29. name: 'app.vue',
  30. language: 'html',
  31. code: `
  32. <script setup>
  33. import { ref, onMounted } from 'vue'
  34. import { createClient } from '@supabase/supabase-js'
  35. const config = useRuntimeConfig()
  36. const briven = createClient(config.public.brivenUrl, config.public.brivenKey)
  37. const todos = ref([])
  38. async function getTodos() {
  39. const { data } = await briven.from('todos').select()
  40. todos.value = data
  41. }
  42. onMounted(() => {
  43. getTodos()
  44. })
  45. </script>
  46. <template>
  47. <ul>
  48. <li v-for="todo in todos" :key="todo.id">{{ todo.name }}</li>
  49. </ul>
  50. </template>
  51. `,
  52. },
  53. ]
  54. return <MultipleCodeBlock files={files} />
  55. }
  56. export default ContentFile