Clarify News category heading and SEO metadata
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
interface OgMeta {
|
interface OgMeta {
|
||||||
|
siteName?: string;
|
||||||
ogTitle?: string;
|
ogTitle?: string;
|
||||||
ogDescription?: string;
|
ogDescription?: string;
|
||||||
ogImage?: string;
|
ogImage?: string;
|
||||||
@@ -52,7 +53,7 @@ function setCanonical(href: string) {
|
|||||||
|
|
||||||
export function usePageMeta(title: string, description?: string, og?: OgMeta) {
|
export function usePageMeta(title: string, description?: string, og?: OgMeta) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const suffix = " | Folx Music Television";
|
const suffix = ` | ${og?.siteName || "Folx Music Television"}`;
|
||||||
document.title = title + suffix;
|
document.title = title + suffix;
|
||||||
if (description) {
|
if (description) {
|
||||||
setMetaTag('meta[name="description"]', description);
|
setMetaTag('meta[name="description"]', description);
|
||||||
@@ -104,5 +105,5 @@ export function usePageMeta(title: string, description?: string, og?: OgMeta) {
|
|||||||
removeMetaTag('meta[property="article:author"]');
|
removeMetaTag('meta[property="article:author"]');
|
||||||
removeMetaTag('meta[property="article:section"]');
|
removeMetaTag('meta[property="article:section"]');
|
||||||
};
|
};
|
||||||
}, [title, description, og?.ogTitle, og?.ogDescription, og?.ogImage, og?.ogType, og?.ogUrl, og?.articlePublishedTime, og?.articleAuthor, og?.articleSection]);
|
}, [title, description, og?.siteName, og?.ogTitle, og?.ogDescription, og?.ogImage, og?.ogType, og?.ogUrl, og?.articlePublishedTime, og?.articleAuthor, og?.articleSection]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,10 +31,20 @@ export default function CategoryPage({ fixedCategory }: { fixedCategory?: string
|
|||||||
const searchParams = new URLSearchParams(searchString);
|
const searchParams = new URLSearchParams(searchString);
|
||||||
const currentPage = Math.max(1, parseInt(searchParams.get("page") || "1"));
|
const currentPage = Math.max(1, parseInt(searchParams.get("page") || "1"));
|
||||||
|
|
||||||
usePageMeta(
|
const isNews = category?.toLowerCase() === "news";
|
||||||
`${category}${currentPage > 1 ? ` – Seite ${currentPage}` : ""} - Volksmusik & Schlager`,
|
const heading = isNews ? "Schlager & Volksmusik News" : category;
|
||||||
`Aktuelle ${category}-Beiträge und Nachrichten aus der Volksmusik- und Schlagerszene. Neueste Volksmusik-Meldungen bei FOLX TV.`
|
const pageSuffix = currentPage > 1 ? ` – Seite ${currentPage}` : "";
|
||||||
);
|
const pageTitle = isNews ? `${heading}${pageSuffix}` : `${category}${pageSuffix} - Volksmusik & Schlager`;
|
||||||
|
const description = isNews
|
||||||
|
? "Aktuelle Schlager & Volksmusik News: Nachrichten, Interviews und Neuigkeiten aus der Musikszene bei FOLX TV."
|
||||||
|
: `Aktuelle ${category}-Beiträge und Nachrichten aus der Volksmusik- und Schlagerszene. Neueste Volksmusik-Meldungen bei FOLX TV.`;
|
||||||
|
|
||||||
|
usePageMeta(pageTitle, description, isNews ? {
|
||||||
|
siteName: "FOLX TV",
|
||||||
|
ogTitle: `${pageTitle} | FOLX TV`,
|
||||||
|
ogDescription: description,
|
||||||
|
ogType: "website",
|
||||||
|
} : undefined);
|
||||||
|
|
||||||
const { data, isLoading } = useQuery<PaginatedResponse>({
|
const { data, isLoading } = useQuery<PaginatedResponse>({
|
||||||
queryKey: ["/api/articles/category", category, { page: currentPage }],
|
queryKey: ["/api/articles/category", category, { page: currentPage }],
|
||||||
@@ -127,8 +137,8 @@ export default function CategoryPage({ fixedCategory }: { fixedCategory?: string
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="flex items-center justify-between gap-2 mb-6 flex-wrap">
|
<div className="flex items-center justify-between gap-2 mb-6 flex-wrap">
|
||||||
<h1 className="text-2xl font-bold text-foreground" data-testid="text-category-title">
|
<h1 className="min-w-0 text-2xl font-bold text-foreground break-words" data-testid="text-category-title">
|
||||||
{category}
|
{heading}
|
||||||
</h1>
|
</h1>
|
||||||
{data && data.total > 0 && (
|
{data && data.total > 0 && (
|
||||||
<span className="text-sm text-muted-foreground" data-testid="text-article-count">
|
<span className="text-sm text-muted-foreground" data-testid="text-article-count">
|
||||||
|
|||||||
+9
-3
@@ -402,8 +402,14 @@ export function serveStatic(app: Express) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const catUrl = `${canonicalBase}/category/${encodeURIComponent(cat)}`;
|
const catUrl = `${canonicalBase}/category/${encodeURIComponent(cat)}`;
|
||||||
const catTitle = `${cat} – Volksmusik & Schlager | Folx Music Television`;
|
const isNews = cat.toLowerCase() === "news";
|
||||||
const catDesc = `Alle Beiträge aus der Rubrik ${cat} bei FOLX TV: aktuelle Meldungen, Interviews und Videos aus Volksmusik und Schlager.`;
|
const catHeading = isNews ? "Schlager & Volksmusik News" : cat;
|
||||||
|
const catTitle = isNews
|
||||||
|
? `${catHeading} | FOLX TV`
|
||||||
|
: `${cat} – Volksmusik & Schlager | Folx Music Television`;
|
||||||
|
const catDesc = isNews
|
||||||
|
? "Aktuelle Schlager & Volksmusik News: Nachrichten, Interviews und Neuigkeiten aus der Musikszene bei FOLX TV."
|
||||||
|
: `Alle Beiträge aus der Rubrik ${cat} bei FOLX TV: aktuelle Meldungen, Interviews und Videos aus Volksmusik und Schlager.`;
|
||||||
const firstImg = ogImageUrl(list[0]?.coverImage || "", canonicalBase) || `${canonicalBase}/og-image.jpg`;
|
const firstImg = ogImageUrl(list[0]?.coverImage || "", canonicalBase) || `${canonicalBase}/og-image.jpg`;
|
||||||
const itemLd = {
|
const itemLd = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
@@ -445,7 +451,7 @@ export function serveStatic(app: Express) {
|
|||||||
}
|
}
|
||||||
const ssr = [
|
const ssr = [
|
||||||
'<section class="ssr-content">',
|
'<section class="ssr-content">',
|
||||||
`<h1>${escapeHtml(cat)}</h1>`,
|
`<h1>${escapeHtml(catHeading)}</h1>`,
|
||||||
"<ul>",
|
"<ul>",
|
||||||
...list.map((a: any) => {
|
...list.map((a: any) => {
|
||||||
const img = ogImageUrl(a.coverImage || "", canonicalBase);
|
const img = ogImageUrl(a.coverImage || "", canonicalBase);
|
||||||
|
|||||||
Reference in New Issue
Block a user