Restored to '3905f52571b4fa7e048e16d7a3b94ee66307d072'

Replit-Restored-To: 3905f52571
This commit is contained in:
sebastjanartic
2026-03-05 12:19:10 +00:00
parent 7434438c1e
commit c13a5150b8
41 changed files with 1706 additions and 667 deletions
+10 -1
View File
@@ -13,6 +13,15 @@ function escapeHtml(str: string): string {
return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
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)}" />`,