Skip to content

Commit 2ddf26e

Browse files
alessiopelliccionekirjs
authored andcommitted
refactor(docs-infra): automate algolia index name based on package version
Previously, the Algolia index name was hardcoded in the configuration, requiring manual updates for every new major release branch. This commit automates the index name selection by deriving the version directly @angular/core. It dynamically assigns: - `angular_next_dev` for pre-releases (`-next`, `-rc`) and local snapshots (`0.0.0`). - `angular_vXX` (e.g., `angular_v19`) for stable releases.
1 parent 889afe9 commit 2ddf26e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

adev/src/app/environment.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import {VERSION} from '@angular/core';
10+
const major = VERSION.major;
11+
12+
const isPreRelease =
13+
VERSION.full.includes('-next') || VERSION.full.includes('-rc') || VERSION.full === '0.0.0';
14+
15+
// NOTE: Although the index name is determined automatically here, the actual index
16+
// must be MANUALLY created on the Algolia dashboard for every new major version.
17+
const indexName = isPreRelease ? 'angular_next_dev' : `angular_v${major}`;
18+
919
export default {
1020
production: true,
1121
// Those values are publicly visible in the search request headers, and presents search-only keys.
1222
// https://www.algolia.com/doc/guides/security/api-keys/#search-only-api-key
1323
algolia: {
1424
appId: 'L1XWT2UJ7F',
1525
apiKey: 'dfca7ed184db27927a512e5c6668b968',
16-
// The indexName value must match the branch it's on.
17-
// So it needs to be updated on release of the new major on the patch branch.
18-
indexName: 'angular_next_dev',
26+
indexName: indexName,
1927
},
2028
googleAnalyticsId: 'G-XB6NEVW32B',
2129
};

0 commit comments

Comments
 (0)