Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new 'mainBranch' parameter #123

Merged
merged 5 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. Usefull when you tweak Algolia search settings. If set, Algolia indices created for other branches will inherit the settings of the mainBranch's index.
sbellone marked this conversation as resolved.
Show resolved Hide resolved
- 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