Update image links for the blog to ensure proper display
Replace old Dropbox image URLs with new Dropbox image URLs in the gallery data JSON file. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1f7e7e89-a520-4970-9645-37daadc466dc Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 2488734a-5aee-4938-b09a-9086e35dacd2 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/1f7e7e89-a520-4970-9645-37daadc466dc/mwtHL8H Replit-Helium-Checkpoint-Created: true
This commit is contained in:
parent
f34d2c156c
commit
0ab24d65a3
BIN
attached_assets/image_1772724003016.png
Normal file
BIN
attached_assets/image_1772724003016.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 188 KiB |
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,7 @@ export function serveStatic(app: Express) {
|
|||||||
const url = req.originalUrl;
|
const url = req.originalUrl;
|
||||||
const indexPath = path.resolve(distPath, "index.html");
|
const indexPath = path.resolve(distPath, "index.html");
|
||||||
|
|
||||||
|
const canonicalBase = "https://www.folx.tv";
|
||||||
const host = req.get("host") || "folx.tv";
|
const host = req.get("host") || "folx.tv";
|
||||||
const protocol = req.get("x-forwarded-proto") || "https";
|
const protocol = req.get("x-forwarded-proto") || "https";
|
||||||
const baseUrl = `${protocol}://${host}`;
|
const baseUrl = `${protocol}://${host}`;
|
||||||
@ -54,9 +55,9 @@ export function serveStatic(app: Express) {
|
|||||||
const slug = decodeURIComponent(articleMatch[1]);
|
const slug = decodeURIComponent(articleMatch[1]);
|
||||||
const article = await storage.getArticleBySlug(slug);
|
const article = await storage.getArticleBySlug(slug);
|
||||||
if (article) {
|
if (article) {
|
||||||
const articleUrl = `${baseUrl}/article/${article.slug}`;
|
const articleUrl = `${canonicalBase}/article/${article.slug}`;
|
||||||
const imageUrl = ogImageUrl(article.coverImage || "", baseUrl);
|
const imageUrl = ogImageUrl(article.coverImage || "", canonicalBase);
|
||||||
const finalImage = imageUrl || `${baseUrl}/og-image.jpg`;
|
const finalImage = imageUrl || `${canonicalBase}/og-image.jpg`;
|
||||||
|
|
||||||
let template = await fs.promises.readFile(indexPath, "utf-8");
|
let template = await fs.promises.readFile(indexPath, "utf-8");
|
||||||
template = stripExistingMeta(template);
|
template = stripExistingMeta(template);
|
||||||
@ -91,9 +92,6 @@ export function serveStatic(app: Express) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let template = await fs.promises.readFile(indexPath, "utf-8");
|
let template = await fs.promises.readFile(indexPath, "utf-8");
|
||||||
template = template.replace(/https:\/\/www\.folx\.tv\//g, `${baseUrl}/`);
|
|
||||||
template = template.replace(/https:\/\/www\.folx\.tv\/og-image\.jpg/g, `${baseUrl}/og-image.jpg`);
|
|
||||||
|
|
||||||
res.status(200).set({ "Content-Type": "text/html" }).end(template);
|
res.status(200).set({ "Content-Type": "text/html" }).end(template);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,14 @@ function ogImageUrl(coverImage: string, baseUrl: string): string {
|
|||||||
return imgPath.startsWith("http") ? imgPath : `${baseUrl}${imgPath}`;
|
return imgPath.startsWith("http") ? imgPath : `${baseUrl}${imgPath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripExistingMeta(html: string): string {
|
||||||
|
html = html.replace(/<meta\s+property="og:[^"]*"[^>]*>\s*/gi, "");
|
||||||
|
html = html.replace(/<meta\s+name="twitter:[^"]*"[^>]*>\s*/gi, "");
|
||||||
|
html = html.replace(/<meta\s+name="description"[^>]*>\s*/gi, "");
|
||||||
|
html = html.replace(/<meta\s+name="keywords"[^>]*>\s*/gi, "");
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
export async function setupVite(server: Server, app: Express) {
|
export async function setupVite(server: Server, app: Express) {
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
middlewareMode: true,
|
middlewareMode: true,
|
||||||
@ -47,6 +55,7 @@ export async function setupVite(server: Server, app: Express) {
|
|||||||
|
|
||||||
app.use("/{*path}", async (req, res, next) => {
|
app.use("/{*path}", async (req, res, next) => {
|
||||||
const url = req.originalUrl;
|
const url = req.originalUrl;
|
||||||
|
const canonicalBase = "https://www.folx.tv";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const clientTemplate = path.resolve(
|
const clientTemplate = path.resolve(
|
||||||
@ -68,28 +77,33 @@ export async function setupVite(server: Server, app: Express) {
|
|||||||
const slug = decodeURIComponent(articleMatch[1]);
|
const slug = decodeURIComponent(articleMatch[1]);
|
||||||
const article = await storage.getArticleBySlug(slug);
|
const article = await storage.getArticleBySlug(slug);
|
||||||
if (article) {
|
if (article) {
|
||||||
const host = req.get("host") || "folx.tv";
|
const articleUrl = `${canonicalBase}/article/${article.slug}`;
|
||||||
const protocol = req.get("x-forwarded-proto") || "https";
|
const imageUrl = ogImageUrl(article.coverImage || "", canonicalBase);
|
||||||
const baseUrl = `${protocol}://${host}`;
|
const finalImage = imageUrl || `${canonicalBase}/og-image.jpg`;
|
||||||
const articleUrl = `${baseUrl}/article/${article.slug}`;
|
|
||||||
const imageUrl = ogImageUrl(article.coverImage || "", baseUrl);
|
template = stripExistingMeta(template);
|
||||||
|
|
||||||
const ogTags = [
|
const ogTags = [
|
||||||
`<meta property="og:title" content="${escapeHtml(article.title)}" />`,
|
`<meta property="og:title" content="${escapeHtml(article.title)}" />`,
|
||||||
`<meta property="og:description" content="${escapeHtml(article.excerpt)}" />`,
|
`<meta property="og:description" content="${escapeHtml(article.excerpt)}" />`,
|
||||||
`<meta property="og:type" content="article" />`,
|
`<meta property="og:type" content="article" />`,
|
||||||
`<meta property="og:url" content="${escapeHtml(articleUrl)}" />`,
|
`<meta property="og:url" content="${escapeHtml(articleUrl)}" />`,
|
||||||
imageUrl ? `<meta property="og:image" content="${escapeHtml(imageUrl)}" />` : "",
|
`<meta property="og:image" content="${escapeHtml(finalImage)}" />`,
|
||||||
|
`<meta property="og:image:secure_url" content="${escapeHtml(finalImage)}" />`,
|
||||||
|
`<meta property="og:image:width" content="800" />`,
|
||||||
|
`<meta property="og:image:height" content="450" />`,
|
||||||
|
`<meta property="og:image:type" content="image/jpeg" />`,
|
||||||
`<meta property="og:site_name" content="Folx Music Television" />`,
|
`<meta property="og:site_name" content="Folx Music Television" />`,
|
||||||
|
`<meta property="og:locale" content="de_DE" />`,
|
||||||
`<meta name="twitter:card" content="summary_large_image" />`,
|
`<meta name="twitter:card" content="summary_large_image" />`,
|
||||||
`<meta name="twitter:title" content="${escapeHtml(article.title)}" />`,
|
`<meta name="twitter:title" content="${escapeHtml(article.title)}" />`,
|
||||||
`<meta name="twitter:description" content="${escapeHtml(article.excerpt)}" />`,
|
`<meta name="twitter:description" content="${escapeHtml(article.excerpt)}" />`,
|
||||||
imageUrl ? `<meta name="twitter:image" content="${escapeHtml(imageUrl)}" />` : "",
|
`<meta name="twitter:image" content="${escapeHtml(finalImage)}" />`,
|
||||||
|
`<meta name="description" content="${escapeHtml(article.excerpt)}" />`,
|
||||||
`<title>${escapeHtml(article.title)} - Folx Music Television</title>`,
|
`<title>${escapeHtml(article.title)} - Folx Music Television</title>`,
|
||||||
].filter(Boolean).join("\n ");
|
].join("\n ");
|
||||||
|
|
||||||
template = template.replace(/<meta property="og:[^"]*"[^>]*\/>\s*/g, "");
|
template = template.replace(/<title>[^<]*<\/title>/, ogTags);
|
||||||
template = template.replace(/<title>.*?<\/title>/, ogTags);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user