Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not show dead guides for superseded extensions #1213

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

}

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 Expand Up @@ -304,7 +304,7 @@
exports.onCreateWebpackConfig = ({ stage }) => {
let plugins
if (stage === "develop") {
plugins = [

Check warning on line 307 in gatsby-node.js

View workflow job for this annotation

GitHub Actions / build

'plugins' is assigned a value but never used
new ESLintPlugin({
extensions: ["js", "jsx", "ts", "tsx"], // | [, "md", "mdx"] or any other files
emitWarning: true,
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
Loading