An atproto based writing game loosely inspired by Fiasco!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

base CRUD

+16 -6
+16 -6
src/routes/index.tsx
··· 1 1 import { createAsync, type RouteDefinition } from "@solidjs/router"; 2 2 import { For } from "solid-js"; 3 - import { getPosts } from "~/db"; 3 + import { action } from "@solidjs/router"; 4 + import { getPosts, insertPost } from "~/db"; 4 5 5 6 export const route = { 6 7 preload() { 7 - getPosts(); 8 + const post = getPosts(); 9 + console.log(post) 10 + return post 8 11 } 9 12 } satisfies RouteDefinition; 10 13 14 + const post = action(async (formData: FormData) => { 15 + "use server"; 16 + const message = formData.get('message') as string; 17 + return await insertPost(message); 18 + }) 19 + 11 20 export default function Home() { 12 21 const posts = createAsync(async () => (await getPosts()).map(post => post.message || ''), { deferStream: true }); 13 22 ··· 18 27 </For> 19 28 {/* <h2 class="font-bold text-3xl">Hello {user()?.username}</h2> */} 20 29 <h3 class="font-bold text-xl">Message board</h3> 21 - {/* <form action={logout} method="post"> 22 - <button name="logout" type="submit"> 23 - Logout 30 + <form action={post} method="post"> 31 + <input type="text" name="message" id="message" /> 32 + <button type="submit"> 33 + Post 24 34 </button> 25 - </form> */} 35 + </form> 26 36 </main> 27 37 ); 28 38 }