Skip to content

Commit

Permalink
Do not show dead guides for superseded extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
holly-cummins committed Nov 4, 2024
1 parent 3fbc391 commit e9044ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/components/util/guide-url-rewriter.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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"),
Expand Down

0 comments on commit e9044ed

Please sign in to comment.