From ed8872226bc783b64f595c2fb24bd26cc8043508 Mon Sep 17 00:00:00 2001 From: folx bot Date: Mon, 24 Aug 2026 22:07:59 +0200 Subject: [PATCH] video strani: cel opis in kazalo gredo v HTML brez JavaScripta, VideoObject description je zdaj daljsi opis in ne le teaser --- server/static.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/static.ts b/server/static.ts index e46fa67..3e1a92f 100644 --- a/server/static.ts +++ b/server/static.ts @@ -131,13 +131,15 @@ export function serveStatic(app: Express) { const pageUrl = `${canonicalBase}/video/${v.slug}`; const poster = `${canonicalBase}${v.posterUrl}`; const desc = (v.teaser || v.shortTitle || v.title).slice(0, 300); + const longDesc = String(v.description || v.teaser || v.shortTitle) + .replace(/https?:\/\/\S+/g, "").replace(/\s+/g, " ").trim().slice(0, 900); const mins = Math.floor((v.durationS || 0) / 60), secs = (v.durationS || 0) % 60; const embedUrl = v.embedUrl || `https://www.youtube-nocookie.com/embed/${v.ytId}`; const videoLd = { "@context": "https://schema.org", "@type": "VideoObject", "name": v.shortTitle, - "description": desc, + "description": longDesc || desc, "thumbnailUrl": [poster], "uploadDate": v.publishedAt, "duration": `PT${mins}M${secs}S`, @@ -176,6 +178,15 @@ export function serveStatic(app: Express) { const chapterHtml = (v.chapters || []).length ? `

Kapitel

` : ""; + // Celoten opis gre v SSR, da ga Google prebere brez JavaScripta. + // Prej je bil v HTML samo naslov in teaser (~320 znakov), ostalo je + // izrisal sele React. + const descHtml = String(v.description || "") + .split(/\n{2,}/) + .map((par: string) => par.trim()) + .filter((par: string) => par.length > 2 && !/^https?:\/\//.test(par) && !/^[\u2013\u2014-]{4,}$/.test(par)) + .map((par: string) => `

${escapeHtml(par).replace(/\n/g, "
")}

`) + .join(""); const ssr = [ '
', `

${escapeHtml(v.shortTitle)}

`, @@ -183,6 +194,7 @@ export function serveStatic(app: Express) { `

${escapeHtml(desc)}

`, chapterHtml, `

Das ganze Video auf YouTube ansehen

`, + descHtml ? `

Zum Video

${descHtml}` : "", "
", ].join("\n"); template = template.replace('
', () => `
${ssr}
`);