a tool for shared writing and social publishing
0
fork

Configure Feed

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

proxy link preview images

+35 -23
+4 -12
actions/addLinkCard.ts
··· 12 12 description: z.string().optional().nullable(), 13 13 author: z.string().optional().nullable(), 14 14 title: z.string().optional().nullable(), 15 - screenshot: z.object({ 16 - url: z.string(), 17 - width: z.number(), 18 - height: z.number(), 19 - }), 20 15 image: z 21 16 .object({ 22 17 url: z.string(), ··· 37 32 }); 38 33 39 34 export const get_url_preview_data = async (url: string) => { 40 - let response = await fetch( 41 - `https://pro.microlink.io/?url=${url}&screenshot`, 42 - { 43 - headers: { 44 - "x-api-key": process.env.MICROLINK_API_KEY!, 45 - }, 35 + let response = await fetch(`https://pro.microlink.io/?url=${url}`, { 36 + headers: { 37 + "x-api-key": process.env.MICROLINK_API_KEY!, 46 38 }, 47 - ); 39 + }); 48 40 49 41 let result = expectedAPIResponse.safeParse(await response.json()); 50 42 return result;
+11 -11
src/utils/addLinkBlock.ts
··· 21 21 value: url, 22 22 }, 23 23 }); 24 + await rep?.mutate.assertFact({ 25 + entity: entityID, 26 + attribute: "link/preview", 27 + data: { 28 + fallback: "", 29 + type: "image", 30 + src: `/api/link-preview-proxy?url=${url}`, 31 + width: 1920, 32 + height: 1080, 33 + }, 34 + }); 24 35 let data = await addLinkCard({ link: url }); 25 36 if (data.success) { 26 - await rep?.mutate.assertFact({ 27 - entity: entityID, 28 - attribute: "link/preview", 29 - data: { 30 - fallback: "", 31 - type: "image", 32 - src: data.data.data.screenshot.url, 33 - width: data.data.data.screenshot.width, 34 - height: data.data.data.screenshot.height, 35 - }, 36 - }); 37 37 await rep?.mutate.assertFact({ 38 38 entity: entityID, 39 39 attribute: "link/title",