Skip to content

Commit

Permalink
feat: new 'mainBranch' parameter (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbellone committed Nov 18, 2020
1 parent 3b086fb commit 0ca01b6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Read our full documentation [here](../docs/GettingStarted.md)

Plugin inputs can be set in `netlify.toml`. They're all optional.

- `branches` - _Default: `['master']`_ - List of branches the crawler should build.
- `branches` - _Default: `['master', 'main']`_ - List of branches the crawler should build.
By default, we only build your main branch, but this can be used to build multiple branches.
Each of those will have a dedicated Algolia index, named `netlify_<site-id>_<branch-name>_all`.
You will need to [target the right branch](../frontend#using-multiple-branches) in your front-end code.
Expand All @@ -22,6 +22,8 @@ Plugin inputs can be set in `netlify.toml`. They're all optional.
- `feat/*`: matches all branches starting with `feat/`
- `*-bug`: matches all branches finishing with `-bug`
- `disabled` - _Default: `false`_ - Use to disable the plugin without removing it.
- `mainBranch` - The main project's branch. If set, it will be used to propagate your [Algolia index settings](https://www.algolia.com/doc/guides/managing-results/relevance-overview/#index-setting-and-query-parameters) modifications to other branches:
Settings of the Algolia index of your main branch will be used to create the new index when the plugin runs for the first time on a new branch.
- `pathPrefix` - The prefix of your website if it's not at the root level.
Putting "pathPrefix: /blog" will alias `/blog` to `/`
- `customDomain` - The custom domain that you use, if it's not possible to define it on your Netlify's settings.
Expand Down
2 changes: 2 additions & 0 deletions plugin/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ inputs:
- name: branches
description: Branches to index. Each branch in this array will have its content crawled in a dedicated index.
default: ['master', 'main']
- name: mainBranch
description: Main working branch. Useful when you tweak Algolia search settings. If set, Algolia indices created for other branches will inherit the settings of the mainBranch's index.
- name: pathPrefix
description: The prefix of your website if it's not at the root level, e.g /blog
- name: customDomain
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function onSuccess(params: BuildParams): Promise<void> {
const algoliaApiKey = process.env.ALGOLIA_API_KEY;

const branches = inputs.branches;
const mainBranch = inputs.mainBranch;
const pathPrefix = inputs.pathPrefix;
const customDomain = inputs.customDomain;

Expand Down Expand Up @@ -100,6 +101,7 @@ export async function onSuccess(params: BuildParams): Promise<void> {
try {
const body = JSON.stringify({
branch,
mainBranch,
siteName,
deployPrimeUrl,
version,
Expand Down
1 change: 1 addition & 0 deletions plugin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface BuildParams {
inputs: {
disabled: boolean;
branches: string[];
mainBranch?: string;
pathPrefix?: string;
customDomain?: string;
};
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_netlify_toml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dev_only='
package = "./plugin/dist/index.js"
[plugins.inputs]
branches = ["*"]
mainBranch = "master"
[[plugins]]
package = "@algolia/netlify-plugin-crawler"
Expand Down

0 comments on commit 0ca01b6

Please sign in to comment.