From 949083ddb41067368bc3638303683e1340614563 Mon Sep 17 00:00:00 2001 From: Isabel Tomb Date: Mon, 8 Jul 2024 13:03:39 -0500 Subject: [PATCH] Update `patchMkdocsYmlPreBuild` Update the `patchMkdocsYmlPreBuild` function to modify `repo_url` and `edit_uri` independently of each other. Prior to this change both `repo_url` and `edit_uri` would have to be missing for either to be generated which caused an issue in the situation where `repo_url` is provided in the mkdocs.yml and `edit_uri` is not because the default `edit_uri` value from mkdocs would be used instead. This value uses `master` as the branch in the link which breaks the edit link for repos that don't use `master` as the default branch. Signed-off-by: Isabel Tomb --- .changeset/mighty-geckos-kiss.md | 5 +++++ plugins/techdocs-node/src/stages/generate/mkdocsPatchers.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/mighty-geckos-kiss.md diff --git a/.changeset/mighty-geckos-kiss.md b/.changeset/mighty-geckos-kiss.md new file mode 100644 index 0000000000..0761d8b257 --- /dev/null +++ b/.changeset/mighty-geckos-kiss.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Update `patchMkdocsYmlPrebuild` to modify `repo_url` and `edit_uri` independently. diff --git a/plugins/techdocs-node/src/stages/generate/mkdocsPatchers.ts b/plugins/techdocs-node/src/stages/generate/mkdocsPatchers.ts index 762a1c267a..fb95c19a9c 100644 --- a/plugins/techdocs-node/src/stages/generate/mkdocsPatchers.ts +++ b/plugins/techdocs-node/src/stages/generate/mkdocsPatchers.ts @@ -108,7 +108,7 @@ export const patchMkdocsYmlPreBuild = async ( scmIntegrations: ScmIntegrationRegistry, ) => { await patchMkdocsFile(mkdocsYmlPath, logger, mkdocsYml => { - if (!('repo_url' in mkdocsYml) && !('edit_uri' in mkdocsYml)) { + if (!('repo_url' in mkdocsYml) || !('edit_uri' in mkdocsYml)) { // Add edit_uri and/or repo_url to mkdocs.yml if it is missing. // This will enable the Page edit button generated by MkDocs. // If the either has been set, keep the original value @@ -119,8 +119,8 @@ export const patchMkdocsYmlPreBuild = async ( ); if (result.repo_url || result.edit_uri) { - mkdocsYml.repo_url = result.repo_url; - mkdocsYml.edit_uri = result.edit_uri; + mkdocsYml.repo_url = mkdocsYml.repo_url || result.repo_url; + mkdocsYml.edit_uri = mkdocsYml.edit_uri || result.edit_uri; logger.info( `Set ${JSON.stringify(