diff --git a/.changeset/ten-cups-relax.md b/.changeset/ten-cups-relax.md new file mode 100644 index 0000000000..9e32ad3856 --- /dev/null +++ b/.changeset/ten-cups-relax.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': patch +--- + +Make git config optional for techdocs feedback links diff --git a/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts b/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts index d19d90228c..c74f06934d 100644 --- a/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts +++ b/plugins/techdocs/src/reader/transformers/addGitFeedbackLink.ts @@ -35,20 +35,20 @@ export const addGitFeedbackLink = (configApi: any): Transformer => { const sourceURL = new URL(sourceAnchor.href); const githubHosts = configApi - .getConfigArray('integrations.github') - .map((integration: any) => integration.data.host); + .getOptionalConfigArray('integrations.github') + ?.map((integration: any) => integration.data.host); const gitlabHosts = configApi - .getConfigArray('integrations.gitlab') - .map((integration: any) => integration.data.host); + .getOptionalConfigArray('integrations.gitlab') + ?.map((integration: any) => integration.data.host); // don't show if can't identify edit link hostname as a gitlab/github hosting if ( - githubHosts.includes(sourceURL.hostname) || + githubHosts?.includes(sourceURL.hostname) || sourceURL.origin.includes('github') ) { gitHost = 'github'; } else if ( - gitlabHosts.includes(sourceURL.hostname) || + gitlabHosts?.includes(sourceURL.hostname) || sourceURL.origin.includes('gitlab') ) { gitHost = 'gitlab';