From e9044ed43ef25c43457d11d993d30e30b5c1b543 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 | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index 31ba5112ed56..e3a7ae6d0b8a 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(node) + 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..17c034daebfb 100644 --- a/src/components/util/guide-url-rewriter.js +++ b/src/components/util/guide-url-rewriter.js @@ -1,4 +1,4 @@ -const rewriteGuideUrl = async ({ name, metadata }) => { +const rewriteGuideUrl = async ({ name, metadata, isSuperseded }) => { // We have to access the url exist as a dynamic import (because CJS), await it because dynamic imports give a promise, and then destructure it to get the default // A simple property read won't work const { @@ -21,6 +21,14 @@ const rewriteGuideUrl = async ({ name, metadata }) => { originalLink ) return undefined + } else if (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"),