From 111d55097c63794e7a4f60f784a5da55cd370409 Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Mon, 17 Oct 2022 22:51:59 +0200 Subject: [PATCH 1/3] Ignore missing URL --- plugins/gatsby-source-jenkinsplugins/utils.js | 6 ++++-- plugins/plugin-site/src/templates/plugin.jsx | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/gatsby-source-jenkinsplugins/utils.js b/plugins/gatsby-source-jenkinsplugins/utils.js index 5dfd7231e..f04df9a4f 100644 --- a/plugins/gatsby-source-jenkinsplugins/utils.js +++ b/plugins/gatsby-source-jenkinsplugins/utils.js @@ -75,7 +75,7 @@ const getPluginContent = async ({wiki, pluginName, reporter, createNode, createC id: `${pluginName} <<< JenkinsPluginWiki`, name: pluginName, url: url, - baseHref: `${path.dirname(url)}/`, + baseHref: `${url && path.dirname(url)}/`, internal: { type: 'JenkinsPluginWiki', content: content, @@ -84,7 +84,9 @@ const getPluginContent = async ({wiki, pluginName, reporter, createNode, createC } }); }; - + if (!wiki.url) { + return null; + } if (!shouldFetchPluginContent(pluginName)) { return createWikiNode('text/pluginhtml', wiki.url, ''); } diff --git a/plugins/plugin-site/src/templates/plugin.jsx b/plugins/plugin-site/src/templates/plugin.jsx index 294f2cc66..713fefdea 100644 --- a/plugins/plugin-site/src/templates/plugin.jsx +++ b/plugins/plugin-site/src/templates/plugin.jsx @@ -37,6 +37,9 @@ const PluginWikiContent = ({wiki}) => { if (wiki?.childHtmlRehype) { return
; } + if (!wiki) { + return (
No documentation found for this plugin.
) + } return (
Documentation for this plugin is here: {' '} @@ -181,21 +184,19 @@ function PluginPage({data: {jenkinsPlugin: plugin, reverseDependencies: reverseD
Maintainers
- {shouldShowWikiUrl(plugin.wiki) && + {shouldShowWikiUrl(plugin.wiki || {}) &&
Help us improve this page!
{'This content is served from the '} Jenkins Wiki Export {' which is now '} permanently offline - {' and before that a '} - read-only state {'. We would love your help in moving plugin documentation to GitHub, see '} the guidelines {'.'}
} - {shouldShowGitHubUrl(plugin.wiki) && + {shouldShowGitHubUrl(plugin.wiki || {}) &&
Help us improve this page!
{'To propose a change submit a pull request to '} From a37700651dabc1760f639e8a979af8179d6a061d Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Mon, 17 Oct 2022 23:44:12 +0200 Subject: [PATCH 2/3] Lint fix --- plugins/plugin-site/src/templates/plugin.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin-site/src/templates/plugin.jsx b/plugins/plugin-site/src/templates/plugin.jsx index 713fefdea..2ab22f031 100644 --- a/plugins/plugin-site/src/templates/plugin.jsx +++ b/plugins/plugin-site/src/templates/plugin.jsx @@ -38,7 +38,7 @@ const PluginWikiContent = ({wiki}) => { return
; } if (!wiki) { - return (
No documentation found for this plugin.
) + return (
No documentation found for this plugin.
); } return (
Documentation for this plugin is here: From 047649cbfd8d7e001358c61a0accef7f5716fa75 Mon Sep 17 00:00:00 2001 From: Gavin Mogan Date: Mon, 17 Oct 2022 16:18:35 -0700 Subject: [PATCH 3/3] PR review fixes --- plugins/gatsby-source-jenkinsplugins/utils.js | 4 ++-- plugins/plugin-site/src/templates/plugin.jsx | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/gatsby-source-jenkinsplugins/utils.js b/plugins/gatsby-source-jenkinsplugins/utils.js index f04df9a4f..427753792 100644 --- a/plugins/gatsby-source-jenkinsplugins/utils.js +++ b/plugins/gatsby-source-jenkinsplugins/utils.js @@ -75,7 +75,7 @@ const getPluginContent = async ({wiki, pluginName, reporter, createNode, createC id: `${pluginName} <<< JenkinsPluginWiki`, name: pluginName, url: url, - baseHref: `${url && path.dirname(url)}/`, + baseHref: `${path.dirname(url)}/`, internal: { type: 'JenkinsPluginWiki', content: content, @@ -478,7 +478,7 @@ const fetchPluginVersions = async ({createNode, reporter, firstReleases}) => { if (!firstReleases[data.name] || firstReleases[data.name].getTime() > date.getTime()) { firstReleases[data.name] = date; } - delete(data.buildDate); + delete (data.buildDate); createNode({ ...data, releaseTimestamp: date, diff --git a/plugins/plugin-site/src/templates/plugin.jsx b/plugins/plugin-site/src/templates/plugin.jsx index 2ab22f031..d7dd033c7 100644 --- a/plugins/plugin-site/src/templates/plugin.jsx +++ b/plugins/plugin-site/src/templates/plugin.jsx @@ -22,15 +22,15 @@ import PluginIssueTrackers from '../components/PluginIssueTrackers'; import {useSelectedPluginTab} from '../hooks/useSelectedTab'; -function shouldShowWikiUrl({url}) { +function shouldShowWikiUrl(url) { return url?.startsWith('https://wiki.jenkins-ci.org/') || url?.startsWith('https://wiki.jenkins.io/') || url?.includes('github.com/jenkins-infra/plugins-wiki-docs') || url?.includes('raw.githubusercontent.com/jenkins-infra/plugins-wiki-doc'); } -function shouldShowGitHubUrl({url}) { - return url?.startsWith('https://github.com/') && !shouldShowWikiUrl({url}); +function shouldShowGitHubUrl(url) { + return url?.startsWith('https://github.com/') && !shouldShowWikiUrl(url); } const PluginWikiContent = ({wiki}) => { @@ -184,7 +184,7 @@ function PluginPage({data: {jenkinsPlugin: plugin, reverseDependencies: reverseD
Maintainers
- {shouldShowWikiUrl(plugin.wiki || {}) && + {shouldShowWikiUrl(plugin?.wiki?.url) &&
Help us improve this page!
{'This content is served from the '} @@ -196,7 +196,7 @@ function PluginPage({data: {jenkinsPlugin: plugin, reverseDependencies: reverseD {'.'}
} - {shouldShowGitHubUrl(plugin.wiki || {}) && + {shouldShowGitHubUrl(plugin?.wiki?.url) &&
Help us improve this page!
{'To propose a change submit a pull request to '}