Skip to content

Commit a09e347

Browse files
fix: Handle missing Algolia credentials in local development - Modified export-content-extension.js to gracefully skip Algolia indexing when credentials are missing - Added hasAlgoliaCredentials() function to check for required environment variables - Created scripts/dev-server.sh for simplified local development workflow - Resolves npm run start:dev failures due to missing ALGOLIA_APP_ID, ALGOLIA_ADMIN_KEY, and ALGOLIA_INDEX_NAME (#95)
Co-authored-by: joshassad1 <[email protected]>
1 parent 39665e1 commit a09e347

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

extensions/export-content-extension.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports.register = function () {
1717
await fsPromises.writeFile(outPath, JSON.stringify({ pages }, null, 2));
1818
console.log(`Wrote JSON to ${outPath}`);
1919

20-
if (!shouldSkipIndexing() && !hasIndexed(tempDir)) {
20+
if (!shouldSkipIndexing() && !hasIndexed(tempDir) && hasAlgoliaCredentials()) {
2121
try {
2222
await indexToAlgolia(pages);
2323
await fsPromises.writeFile(path.join(tempDir, 'algolia-indexed.marker'), new Date().toISOString());
@@ -26,7 +26,7 @@ module.exports.register = function () {
2626
console.error('Error indexing to Algolia:', err);
2727
}
2828
} else {
29-
console.log('Skipping Algolia indexing');
29+
console.log('Skipping Algolia indexing (missing credentials or already indexed)');
3030
}
3131
});
3232
};
@@ -94,6 +94,13 @@ function hasIndexed(dir) {
9494
return fs.existsSync(path.join(dir, 'algolia-indexed.marker'));
9595
}
9696

97+
function hasAlgoliaCredentials() {
98+
const appId = process.env.ALGOLIA_APP_ID;
99+
const apiKey = process.env.ALGOLIA_ADMIN_KEY;
100+
const indexName = process.env.ALGOLIA_INDEX_NAME;
101+
return !!(appId && apiKey && indexName);
102+
}
103+
97104
/**
98105
* Chunk pages into smaller records to meet Algolia's 10KB limit.
99106
*/

scripts/dev-server.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
echo "Starting CircleCI Docs development server..."
4+
5+
# Build the UI bundle
6+
echo "Building UI bundle..."
7+
npm run build:ui
8+
9+
# Build the documentation site (without Algolia extension to avoid credential issues)
10+
echo "Building documentation..."
11+
npx antora antora-playbook.yml --extension ./extensions/page-metadata-extension.js
12+
13+
# Start the development server
14+
echo "Starting development server on http://localhost:3000..."
15+
echo "Press Ctrl+C to stop the server"
16+
cd build && python3 -m http.server 3000

0 commit comments

Comments
 (0)