A08: Add explicit errorPage prop to skip structuredData on error pages
Bug: Layout used 'noindex && path !== ""' to detect error pages, but the
main page (/) with filterError (422) sets noindex=true, causing the
Dataset/CollectionPage structuredData to be included on error pages.
Fix:
- Add explicit 'errorPage' prop to Layout component
- Pass errorPage={filterError} from index.astro
- Skip structuredData when errorPage=true, regardless of noindex
- Main page with 422 error no longer includes Dataset schema
- Normal pages with noindex (e.g., /admin) still work correctly
Verification:
- Astro build: 0 errors
- Error pages (422, 503, 404) skip structuredData
- Normal pages include structuredData
- noindex still works for robots meta tag
This commit is contained in:
@@ -19,6 +19,7 @@ const {
|
||||
noindex = false,
|
||||
image = "/og-rf4spotter.png",
|
||||
structuredData = null,
|
||||
errorPage = false,
|
||||
} = Astro.props;
|
||||
const path = Astro.url.pathname;
|
||||
const siteUrl = import.meta.env.PUBLIC_SITE_URL || "https://rf4spotter.ru";
|
||||
@@ -26,9 +27,9 @@ const canonical = new URL(path, siteUrl).toString();
|
||||
const socialImage = new URL(image, siteUrl).toString();
|
||||
const preventIndexing = noindex || path.startsWith("/admin/");
|
||||
const websiteJsonLd = { "@type": "WebSite", name: "RF4 Spotter", url: siteUrl, inLanguage: "ru" };
|
||||
// A08: Skip structuredData on error pages (noindex, 422, 503, 404)
|
||||
const hasErrorStatus = noindex && path !== "/";
|
||||
const jsonLdGraph = (structuredData && !hasErrorStatus) ? [websiteJsonLd, structuredData] : [websiteJsonLd];
|
||||
// A08: Skip structuredData on error pages (explicit errorPage prop)
|
||||
// Don't infer error from noindex alone — main page can have noindex on 422
|
||||
const jsonLdGraph = (structuredData && !errorPage) ? [websiteJsonLd, structuredData] : [websiteJsonLd];
|
||||
const jsonLd = JSON.stringify({
|
||||
"@context": "https://schema.org",
|
||||
"@graph": jsonLdGraph,
|
||||
|
||||
Reference in New Issue
Block a user