Leaflet Blog in Deno Fresh
1import { useSignal } from "@preact/signals";
2import { useEffect } from "preact/hooks";
3import { PostListItem } from "../components/post-list-item.tsx";
4
5interface PostRecord {
6 value: any;
7 uri: string;
8}
9
10export default function PostList({ posts: initialPosts }: { posts: PostRecord[] }) {
11 const posts = useSignal(initialPosts);
12
13 useEffect(() => {
14 posts.value = initialPosts;
15 }, [initialPosts]);
16
17 return (
18 <>
19 {posts.value?.map((record) => {
20 const post = record.value;
21 const rkey = record.uri.split("/").pop() || "";
22 return (
23 <PostListItem
24 key={record.uri}
25 post={post}
26 rkey={rkey}
27 />
28 );
29 })}
30 </>
31 );
32}