Add structured data for news and improved social sharing
Implement NewsArticle schema and Open Graph tags on article pages for better search engine visibility and social media previews, and add WebSite schema to the homepage. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 23852c00-4779-460a-9e0c-d09fee4b6c92 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: b02ed261-705f-4f15-a1ae-b9b80b538081 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/23852c00-4779-460a-9e0c-d09fee4b6c92/koutl3W Replit-Helium-Checkpoint-Created: true
This commit is contained in:
@@ -101,11 +101,67 @@ export default function ArticlePage() {
|
||||
queryKey: ["/api/articles", slug],
|
||||
});
|
||||
|
||||
const articleUrl = article ? `${window.location.origin}/article/${article.slug}` : "";
|
||||
const articleImage = article?.coverImage
|
||||
? (article.coverImage.startsWith("http") ? article.coverImage : `${window.location.origin}${article.coverImage}`)
|
||||
: "";
|
||||
|
||||
usePageMeta(
|
||||
article ? `${article.title} - Volksmusik & Schlager` : "Volksmusik & Schlager Artikel",
|
||||
article?.excerpt || "Aktuelle Nachrichten aus der Volksmusik- und Schlagerszene bei FOLX TV."
|
||||
article?.excerpt || "Aktuelle Nachrichten aus der Volksmusik- und Schlagerszene bei FOLX TV.",
|
||||
article ? {
|
||||
ogTitle: article.title,
|
||||
ogDescription: article.excerpt,
|
||||
ogImage: articleImage || undefined,
|
||||
ogType: "article",
|
||||
ogUrl: articleUrl,
|
||||
} : undefined
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!article) return;
|
||||
const jsonLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"headline": article.title,
|
||||
"description": article.excerpt,
|
||||
"image": articleImage ? [articleImage] : [],
|
||||
"datePublished": new Date(article.publishedAt).toISOString(),
|
||||
"dateModified": new Date(article.publishedAt).toISOString(),
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": article.author || "Folx Music Television",
|
||||
"url": "https://folx.tv"
|
||||
},
|
||||
"publisher": {
|
||||
"@type": "Organization",
|
||||
"name": "Folx Music Television",
|
||||
"url": "https://folx.tv",
|
||||
"logo": {
|
||||
"@type": "ImageObject",
|
||||
"url": `${window.location.origin}/favicon.png`
|
||||
}
|
||||
},
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": articleUrl
|
||||
},
|
||||
"articleSection": article.category || "News",
|
||||
"inLanguage": "de"
|
||||
};
|
||||
const script = document.createElement("script");
|
||||
script.type = "application/ld+json";
|
||||
script.id = "article-jsonld";
|
||||
script.textContent = JSON.stringify(jsonLd);
|
||||
const existing = document.getElementById("article-jsonld");
|
||||
if (existing) existing.remove();
|
||||
document.head.appendChild(script);
|
||||
return () => {
|
||||
const el = document.getElementById("article-jsonld");
|
||||
if (el) el.remove();
|
||||
};
|
||||
}, [article, articleUrl, articleImage]);
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [slug]);
|
||||
|
||||
Reference in New Issue
Block a user