Update image links to ensure compatibility with social media sharing
Updates image URLs in gallery data to use JPG versions instead of WebP for better compatibility with social media platforms like Facebook. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: e03bc7c6-5eed-4f6c-9e9c-90776ba7f5d7 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/EtK2Sno Replit-Helium-Checkpoint-Created: true
This commit is contained in:
+10
-1
@@ -13,6 +13,15 @@ function escapeHtml(str: string): string {
|
||||
return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
|
||||
function ogImageUrl(coverImage: string, baseUrl: string): string {
|
||||
if (!coverImage) return "";
|
||||
let imgPath = coverImage;
|
||||
if (imgPath.endsWith(".webp")) {
|
||||
imgPath = imgPath.replace(/\.webp$/, ".jpg");
|
||||
}
|
||||
return imgPath.startsWith("http") ? imgPath : `${baseUrl}${imgPath}`;
|
||||
}
|
||||
|
||||
export async function setupVite(server: Server, app: Express) {
|
||||
const serverOptions = {
|
||||
middlewareMode: true,
|
||||
@@ -63,7 +72,7 @@ export async function setupVite(server: Server, app: Express) {
|
||||
const protocol = req.get("x-forwarded-proto") || "https";
|
||||
const baseUrl = `${protocol}://${host}`;
|
||||
const articleUrl = `${baseUrl}/article/${article.slug}`;
|
||||
const imageUrl = article.coverImage ? (article.coverImage.startsWith("http") ? article.coverImage : `${baseUrl}${article.coverImage}`) : "";
|
||||
const imageUrl = ogImageUrl(article.coverImage || "", baseUrl);
|
||||
|
||||
const ogTags = [
|
||||
`<meta property="og:title" content="${escapeHtml(article.title)}" />`,
|
||||
|
||||
Reference in New Issue
Block a user