mintlify / docs

🪴 Mintlify's documentation

Home Page:https://mintlify.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide mint.json configuration option to customise suggest edit branch

rifont opened this issue · comments

Problem

Novu docs (https://github.com/novuhq/docs) use a Gitflow branching model with 2 primary branches. All changes first make their way into a trunk branch, and the trunk is periodically merged into the Mintlify deploy branch.

By default, the Mintlify "Suggest edit" feature opens the Github edit page on the deploy branch for the docs, which for repositories using a Gitflow branching model, is the incorrect branch for edits to be made on. This results in poor contributor DX and can result in edits erroneously being pushed against the deploy branch if branch merge checks are not enforced.

Proposed Feature

The mint.json should provide an optional feedback.suggestEditBranch configuration option to enable customisation of the "Suggest edits" branch. If the optional configuration option is not provided, the auto-generated repo.github.deployBranch option should be used.

Proposed Solution

The useUserFeedBack hook can be updated with the following code to support this backward compatible change:

const { suggestEditBranch } = mintConfig?.feedback;
let editBranch;
if (suggestEditBranch) {
    editBranch = suggestEditBranch;
} else {
    editBranch = deployBranch;
}
...
dispatch({
    type: FeedBackActionEnum.SET_CREATE_SUGGEST_HREF,
    payload: `https://github.com/${owner}/${repo}/edit/${editBranch}/${removeFirstSlash(urlPath)}${removeFirstSlash(`${path}.mdx`)}`
});

Who will benefit from this feature?

  • Mintlify customers using a Gitflow branching model to manage changes
  • Mintlify customers preferring suggested edits to be made against a custom branch
  • Contributors to public documentation using the Mintlify platform

I am willing to contribute to the https://github.com/mintlify/docs to support this feature.