feat: allow user to specify deploymentBranch property in docusaurus.config.js (#5841)

* feat: allow user to specify deploymentBranch property in docusaurus.config.js

* docs: remove extra backtick

* docs: fix broken code block
This commit is contained in:
William Poetra Yoga 2021-10-31 11:29:22 +07:00 committed by GitHub
parent 6ccda86e0f
commit ca9bd244aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 6 deletions

View file

@ -109,13 +109,18 @@ This behavior can have SEO impacts and create relative link issues.
// - Site url: https://<organization>.github.io
const isGitHubPagesOrganizationDeploy =
projectName.indexOf('.github.io') !== -1;
if (isGitHubPagesOrganizationDeploy && !process.env.DEPLOYMENT_BRANCH) {
if (
isGitHubPagesOrganizationDeploy &&
!process.env.DEPLOYMENT_BRANCH &&
!siteConfig.deploymentBranch
) {
throw new Error(`For GitHub pages organization deployments, 'docusaurus deploy' does not assume anymore that 'master' is your default Git branch.
Please provide the branch name to deploy to as an environment variable.
Try using DEPLOYMENT_BRANCH=main or DEPLOYMENT_BRANCH=master`);
Please provide the branch name to deploy to as an environment variable, for example DEPLOYMENT_BRANCH=main or DEPLOYMENT_BRANCH=master .
You can also set the deploymentBranch property in docusaurus.config.js .`);
}
const deploymentBranch = process.env.DEPLOYMENT_BRANCH || 'gh-pages';
const deploymentBranch =
process.env.DEPLOYMENT_BRANCH || siteConfig.deploymentBranch || 'gh-pages';
console.log(`${chalk.cyan('deploymentBranch:')} ${deploymentBranch}`);
const githubHost =

View file

@ -143,6 +143,7 @@ export const ConfigSchema = Joi.object({
.default(DEFAULT_CONFIG.onDuplicateRoutes),
organizationName: Joi.string().allow(''),
projectName: Joi.string().allow(''),
deploymentBranch: Joi.string().optional(),
customFields: Joi.object().unknown().default(DEFAULT_CONFIG.customFields),
githubHost: Joi.string(),
plugins: Joi.array().items(PluginSchema).default(DEFAULT_CONFIG.plugins),