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:
ik
2026-09-10 18:17:13 +07:00
parent 56ce498eac
commit 0e592ea404
2 changed files with 5 additions and 4 deletions
+4 -3
View File
@@ -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,
+1 -1
View File
@@ -57,7 +57,7 @@ const datasetJsonLd = {
creator: { "@type": "Organization", name: "RF4 Spotter" }, isAccessibleForFree: true,
};
---
<Layout title="Что клюёт сейчас в Russian Fishing 4 — RF4 Spotter" description="Свежие точки клёва RF4, рабочие приманки, вес уловов и прозрачная оценка данных с указанием каждого источника." structuredData={datasetJsonLd} noindex={showNoIndex}>
<Layout title="Что клюёт сейчас в Russian Fishing 4 — RF4 Spotter" description="Свежие точки клёва RF4, рабочие приманки, вес уловов и прозрачная оценка данных с указанием каждого источника." structuredData={datasetJsonLd} noindex={showNoIndex} errorPage={filterError}>
<section class="intro content-grid"><div class="intro-copy"><span class="eyebrow"><b>RF4</b> Живая карта клёва</span><h1>Выбирай место,<br/><em>пока клюёт.</em></h1><p>Свежие точки, рабочие приманки и честная оценка данных от игроков.</p></div><div class="lake-card"><img src="/lake-dawn.webp" alt="Туманное озеро на рассвете" width="1774" height="887" fetchpriority="high"/><div class="lake-overlay"><div><span class="overline">Пульс водоёмов</span><strong>{items.length} {plural(items.length, ["точка показывает", "точки показывают", "точек показывают"])} активность</strong></div><div class="pulse-orb"><span></span></div></div></div></section>
<section class="filters-wrap"><form class="filters content-grid" method="get" action="/#results">
<label>Водоём<select name="waterbody"><option value="">Все водоёмы</option>{waterbodies.map(x => <option value={x.slug} selected={waterbody === x.slug}>{x.name_ru}</option>)}</select></label>