+import type { Post } from '$lib/data/types';
+
+const client = createClient(supabase.url, supabase.key);
+
+export const post = (id: string, withTopic = false) =>
+ single<Post>(
+ client
+ .from('posts')
+ .select(
+ withTopic
+ ? `*,
+ topic:topic_id (
+ *
+ )
+ `
+ : '*'
+ )
+ .eq('id', id),
+ null
+ );