video strani: cel opis in kazalo gredo v HTML brez JavaScripta, VideoObject description je zdaj daljsi opis in ne le teaser
This commit is contained in:
+13
-1
@@ -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
|
||||
? `<h2>Kapitel</h2><ul>${v.chapters.map((c: any) => `<li>${escapeHtml(c.t)} – ${escapeHtml(c.label)}</li>`).join("")}</ul>`
|
||||
: "";
|
||||
// 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) => `<p>${escapeHtml(par).replace(/\n/g, "<br />")}</p>`)
|
||||
.join("");
|
||||
const ssr = [
|
||||
'<article class="ssr-content">',
|
||||
`<h1>${escapeHtml(v.shortTitle)}</h1>`,
|
||||
@@ -183,6 +194,7 @@ export function serveStatic(app: Express) {
|
||||
`<p><strong>${escapeHtml(desc)}</strong></p>`,
|
||||
chapterHtml,
|
||||
`<p><a href="${escapeHtml(v.youtubeUrl)}" rel="noopener">Das ganze Video auf YouTube ansehen</a></p>`,
|
||||
descHtml ? `<h2>Zum Video</h2>${descHtml}` : "",
|
||||
"</article>",
|
||||
].join("\n");
|
||||
template = template.replace('<div id="root"></div>', () => `<div id="root">${ssr}</div>`);
|
||||
|
||||
Reference in New Issue
Block a user