Skip to content

Commit

Permalink
add image to snippet metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
echo8 committed Dec 22, 2024
1 parent 9327852 commit e19e368
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Binary file added src/client/public/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/server/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export const createExpressRouter = (ctx: AppContext) => {
const snippet = await ctx.snippetService.get(did, rkey);
if (snippet) {
const url = `${env.PUBLIC_URL}/user/${snippet.authorDid}/snippet/${snippet.rkey}`;
return res.render("snippet", { snippet: snippet, url: url });
return res.render("snippet", {
snippet: snippet,
url: url,
imageUrl: env.OG_IMAGE_URL,
});
}
}
return res.status(404).send();
Expand Down
6 changes: 6 additions & 0 deletions src/server/src/util/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ export const env = cleanEnv(process.env, {
dev: "ws://localhost:6008/subscribe",
}),
}),
OG_IMAGE_URL: str({
default: match({
prod: "https://pastesphere.link/icon-512x512.png",
dev: "http://pastesphere.localhost/icon-512x512.png",
}),
}),
});
1 change: 1 addition & 0 deletions src/server/views/snippet.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<meta property="og:type" content="website" />
<meta property="og:url" content="<%=url%>" />
<meta property="og:site_name" content="Pastesphere" />
<meta property="og:image" content="<%=imageUrl%>" />
<meta name="description" content="<%=snippet.description%>" />
<link rel="canonical" href="<%=url%>" />
</head>
Expand Down

0 comments on commit e19e368

Please sign in to comment.