a tool for shared writing and social publishing
0
fork

Configure Feed

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

handle 404 for icon generation

+16 -13
+16 -13
app/[doc_id]/icon.tsx
··· 28 28 .eq("id", props.params.doc_id) 29 29 .single(); 30 30 let rootEntity = res.data?.root_entity; 31 - if (!rootEntity || !res.data) return { title: "Doc not found" }; 32 - let { data } = await supabase.rpc("get_facts", { 33 - root: rootEntity, 34 - }); 35 - let initialFacts = (data as unknown as Fact<keyof typeof Attributes>[]) || []; 36 - let themeCardBG = initialFacts.find( 37 - (f) => f.attribute === "theme/card-background", 38 - ) as Fact<"theme/card-background"> | undefined; 31 + let outlineColor, fillColor; 32 + if (rootEntity && res.data) { 33 + let { data } = await supabase.rpc("get_facts", { 34 + root: rootEntity, 35 + }); 36 + let initialFacts = 37 + (data as unknown as Fact<keyof typeof Attributes>[]) || []; 38 + let themeCardBG = initialFacts.find( 39 + (f) => f.attribute === "theme/card-background", 40 + ) as Fact<"theme/card-background"> | undefined; 39 41 40 - let themePrimary = initialFacts.find( 41 - (f) => f.attribute === "theme/primary", 42 - ) as Fact<"theme/primary"> | undefined; 42 + let themePrimary = initialFacts.find( 43 + (f) => f.attribute === "theme/primary", 44 + ) as Fact<"theme/primary"> | undefined; 43 45 44 - let outlineColor = parseHSBToRGB(`hsba(${themeCardBG?.data.value})`); 46 + outlineColor = parseHSBToRGB(`hsba(${themeCardBG?.data.value})`); 45 47 46 - let fillColor = parseHSBToRGB(`hsba(${themePrimary?.data.value})`); 48 + fillColor = parseHSBToRGB(`hsba(${themePrimary?.data.value})`); 49 + } 47 50 48 51 return new ImageResponse( 49 52 (