From f835bdad9890641bf3826156101e20972e18c5ff Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Fri, 1 Nov 2024 14:06:19 +0000 Subject: [PATCH] Do not show dead guides for superseded extensions --- gatsby-node.js | 4 ++-- src/components/util/guide-url-rewriter.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 31ba5112ed56..01f3d4c09edd 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -165,8 +165,6 @@ exports.sourceNodes = async ({ node.metadata.minimumJavaVersion = node.metadata["minimum-java-version"] delete node.metadata["minimum-java-version"] - node.metadata.guide = await rewriteGuideUrl(extension) - // Look for extensions which are not the same, but which have the same artifact id // (artifactId is just the 'a' part of the gav, artifact is the whole gav string) @@ -210,6 +208,8 @@ exports.sourceNodes = async ({ } + node.metadata.guide = await rewriteGuideUrl(extension) + if (node.metadata) { // Do the link to the download data node.metadata.downloads = node.metadata?.maven?.artifactId ? `${node.metadata.maven.groupId}:${node.metadata.maven.artifactId}` : undefined diff --git a/src/components/util/guide-url-rewriter.js b/src/components/util/guide-url-rewriter.js index 27d0c4fad3c4..44826294a3b1 100644 --- a/src/components/util/guide-url-rewriter.js +++ b/src/components/util/guide-url-rewriter.js @@ -21,6 +21,15 @@ const rewriteGuideUrl = async ({ name, metadata }) => { originalLink ) return undefined + } + if (metadata?.isSuperseded) { + console.warn( + "Stripping dead guide link from superseded extension. Extension is:", + name, + "and guide link is", + originalLink + ) + return undefined } else if (metadata?.guide) { const transforms = [ metadata => metadata.guide.replace("guides", "version/main/guides"),