a tool for shared writing and social publishing
0
fork

Configure Feed

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

add og-image for pub page

+26
+26
app/lish/[did]/[publication]/opengraph-image.ts
··· 1 + import { headers } from "next/headers"; 2 + import { ImageResponse } from "next/og"; 3 + 4 + export const runtime = "edge"; 5 + export const revalidate = 60; 6 + 7 + export default async function OpenGraphImage(props: { 8 + params: { publication: string; did: string }; 9 + }) { 10 + if (process.env.NODE_ENV === "development") return; 11 + const headersList = await headers(); 12 + const hostname = headersList.get("x-forwarded-host"); 13 + let protocol = headersList.get("x-forwarded-proto"); 14 + let path = `${protocol}://${hostname}/lish/${props.params.did}/${props.params.publication}`; 15 + let response = await fetch( 16 + `https://pro.microlink.io/?url=${path}&screenshot=true&viewport.width=1400&viewport.height=733&meta=false&embed=screenshot.url&force=true`, 17 + { 18 + headers: { 19 + "x-api-key": process.env.MICROLINK_API_KEY!, 20 + }, 21 + }, 22 + ); 23 + let endTime = Date.now(); 24 + 25 + return response; 26 + }