SEO: JSON-LD NewsArticle + sitemap.xml + news sitemap + robots.txt + RSS feed
This commit is contained in:
@@ -63,6 +63,38 @@ export function serveStatic(app: Express) {
|
||||
let template = await fs.promises.readFile(indexPath, "utf-8");
|
||||
template = stripExistingMeta(template);
|
||||
|
||||
const pubDate = article.publishedAt
|
||||
? new Date(article.publishedAt as any).toISOString()
|
||||
: new Date().toISOString();
|
||||
const jsonLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"headline": article.title,
|
||||
"description": article.excerpt,
|
||||
"image": [finalImage],
|
||||
"datePublished": pubDate,
|
||||
"dateModified": pubDate,
|
||||
"articleSection": article.category || "News",
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": article.author || "Folx Music Television",
|
||||
"url": canonicalBase,
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": "Folx Music Television",
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": `${canonicalBase}/og-image.jpg`,
|
||||
},
|
||||
},
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": articleUrl,
|
||||
},
|
||||
};
|
||||
const jsonLdTag = `<script type="application/ld+json">${JSON.stringify(jsonLd).replace(/</g, "\\u003c")}</script>`;
|
||||
|
||||
const ogTags = [
|
||||
`<meta property="og:title" content="${escapeHtml(article.title)}" />`,
|
||||
`<meta property="og:description" content="${escapeHtml(article.excerpt)}" />`,
|
||||
@@ -84,6 +116,7 @@ export function serveStatic(app: Express) {
|
||||
`<meta name="keywords" content="Volksmusik, Schlager, ${escapeHtml(article.title)}, ${escapeHtml(article.category || 'News')}, FOLX TV" />`,
|
||||
`<link rel="canonical" href="${escapeHtml(articleUrl)}" />`,
|
||||
`<title>${escapeHtml(article.title)} - Volksmusik & Schlager | Folx Music Television</title>`,
|
||||
jsonLdTag,
|
||||
].join("\n ");
|
||||
|
||||
template = template.replace(/<title>[^<]*<\/title>/, ogTags);
|
||||
|
||||
Reference in New Issue
Block a user