content.tsx 1.6 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. `PUBLIC_BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'}`,
  10. projectKeys?.publishableKey
  11. ? `PUBLIC_BRIVEN_PUBLISHABLE_KEY=${projectKeys.publishableKey}`
  12. : `PUBLIC_BRIVEN_ANON_KEY=${projectKeys.anonKey ?? 'your-anon-key'}`,
  13. '',
  14. ].join('\n'),
  15. },
  16. {
  17. name: 'src/lib/brivenClient.js',
  18. language: 'js',
  19. code: `
  20. import { createClient } from "@supabase/supabase-js";
  21. import { PUBLIC_BRIVEN_URL, ${projectKeys.publishableKey ? 'PUBLIC_BRIVEN_PUBLISHABLE_KEY' : 'PUBLIC_BRIVEN_ANON_KEY'} } from "$env/static/public"
  22. const brivenUrl = PUBLIC_BRIVEN_URL;
  23. const brivenKey = ${projectKeys.publishableKey ? 'PUBLIC_BRIVEN_PUBLISHABLE_KEY' : 'PUBLIC_BRIVEN_ANON_KEY'};
  24. export const briven = createClient(brivenUrl, brivenKey);
  25. `,
  26. },
  27. {
  28. name: 'src/routes/+page.server.js',
  29. language: 'js',
  30. code: `
  31. import { briven } from "$lib/brivenClient";
  32. export async function load() {
  33. const { data } = await briven.from("countries").select();
  34. return {
  35. countries: data ?? [],
  36. };
  37. }
  38. `,
  39. },
  40. {
  41. name: 'src/routes/+page.svelte',
  42. language: 'html',
  43. code: `
  44. <script>
  45. export let data;
  46. </script>
  47. <ul>
  48. {#each data.countries as country}
  49. <li>{country.name}</li>
  50. {/each}
  51. </ul>
  52. `,
  53. },
  54. ]
  55. return <MultipleCodeBlock files={files} />
  56. }
  57. export default ContentFile