Skip to content

Commit 3622c50

Browse files
committed
fix(copilot-review): suppress Article schema on versioned docs roots too
Addresses Copilot comment 3081151415 on PR #832. The previous suppressArticleSchema check only matched /docs/ as the docs root, but this site serves versioned hub pages too — /docs/4.0.0/, /docs/3.0.0/, /docs/2.0.0/, /docs/1.0.0/ — via onlyIncludeVersions and includeCurrentVersion in docusaurus.config.js. Each versioned root is also an index of content with no single author/date/headline, so emitting Article/BlogPosting/APIReference schema on those pages had the same type-mismatch problem the base case fix was addressing. Added a regex check for /docs/<digit-starting-version>/ so any current or archived versioned root is caught by the same suppression path. Current content pages inside versioned trees (e.g. /docs/4.0.0/keploy-explained/how-keploy-works/) still emit Article schema as normal since they have real authors, dates, and headlines — only the bare versioned roots are suppressed. Signed-off-by: Neha Gupta <gneha21@yahoo.in>
1 parent 69e5eee commit 3622c50

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/theme/DocItem/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,23 @@ export default function DocItem(props) {
150150
? metaKeywords.join(", ")
151151
: metaKeywords;
152152
// Suppress Article / BlogPosting / APIReference schema on the /docs/
153-
// root and any category index pages. Article schema on a hub page is
154-
// a type mismatch because a hub does not have a single author, a
155-
// single publication date, or a single headline — it is an index of
156-
// content. Hub pages emit only the normal DocBreadcrumbs JSON-LD.
153+
// root, versioned docs roots like /docs/4.0.0/, and any category
154+
// index pages. Article schema on a hub page is a type mismatch
155+
// because a hub does not have a single author, a single publication
156+
// date, or a single headline — it is an index of content. Hub pages
157+
// emit only the normal DocBreadcrumbs JSON-LD.
157158
const permalink = metadata?.permalink || "";
159+
// Versioned root pattern: /docs/<version>/ or /docs/<version> where
160+
// <version> starts with a digit. Covers current and archived
161+
// versions listed in docusaurus.config.js onlyIncludeVersions.
162+
const isVersionedDocsRoot =
163+
/^\/docs\/\d[\w.-]*(?:\/index)?\/?$/.test(permalink);
158164
const isDocsRoot =
159165
permalink === "/docs/" ||
160166
permalink === "/docs" ||
161167
permalink.endsWith("/docs/index") ||
162-
permalink.endsWith("/docs/");
168+
permalink.endsWith("/docs/") ||
169+
isVersionedDocsRoot;
163170
const isCategoryIndex =
164171
frontMatter?.slug === "index" || /\/category\/|\/index\/?$/.test(permalink);
165172
const suppressArticleSchema = isDocsRoot || isCategoryIndex;

0 commit comments

Comments
 (0)