content.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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: 'src/App.tsx',
  28. language: 'tsx',
  29. code: `
  30. import { briven } from '../utils/briven'
  31. import { createResource, For } from "solid-js";
  32. async function getTodos() {
  33. const { data: todos } = await briven.from("todos").select();
  34. return todos;
  35. }
  36. function App() {
  37. const [todos] = createResource(getTodos);
  38. return (
  39. <ul>
  40. <For each={todos()}>{(todo) => <li>{todo.name}</li>}</For>
  41. </ul>
  42. );
  43. }
  44. export default App;
  45. `,
  46. },
  47. ]
  48. return <MultipleCodeBlock files={files} />
  49. }
  50. export default ContentFile