From 685f7f6c0ff746e1575aa9f964c7f0e8ac04d753 Mon Sep 17 00:00:00 2001 From: "H. Kamran" Date: Wed, 23 Oct 2024 17:33:30 -0700 Subject: [PATCH] Remove Algolia excluded keys (#8231) Signed-off-by: H. Kamran --- scripts/APIv1-frontend.js | 11 ++++++----- scripts/Algolia.js | 9 ++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/APIv1-frontend.js b/scripts/APIv1-frontend.js index dc9f1b5566c..71c120df46d 100644 --- a/scripts/APIv1-frontend.js +++ b/scripts/APIv1-frontend.js @@ -270,12 +270,13 @@ const generateApi = async (entries, categoriesData, regionsData) => { // Write categories.json file const categoriesUsed = categoriesUsedByRegion[region]; - const categoriesDataForRegion = Object.fromEntries( - [...categoriesUsed] - .filter((category) => categoriesData[category]) + const categoriesDataForRegion = Object.fromEntries([ + ...[...categoriesUsed] + .filter((category) => categoriesData[category] && category !== "other") .sort() - .map((category) => [category, categoriesData[category]]) - ); + .map((category) => [category, categoriesData[category]]), + ["other", categoriesData["other"]], + ]); const categoriesWrite = writeJSONFile( path.join(regionDir, "categories.json"), diff --git a/scripts/Algolia.js b/scripts/Algolia.js index 5877cda7d71..cb8501ca4e9 100644 --- a/scripts/Algolia.js +++ b/scripts/Algolia.js @@ -6,13 +6,10 @@ const algoliasearch = require("algoliasearch"); const core = require("@actions/core"); require("dotenv").config(); // Load environment variables from .env file -// List of keys to exclude from the search data -const excludes = ["notes", "documentation", "recovery"]; - // Initialize Algolia client and index using environment variables const client = algoliasearch( process.env.ALGOLIA_APP_ID, - process.env.ALGOLIA_API_KEY, + process.env.ALGOLIA_API_KEY ); const index = client.initIndex(process.env.ALGOLIA_INDEX_NAME); @@ -36,8 +33,6 @@ async function processFile(entry) { ...(categories && { category: categories }), }; - // Remove excluded keys from the data - excludes.forEach((exclude) => delete renamedData[exclude]); return renamedData; } else { // If the file does not exist, remove the corresponding object from Algolia @@ -56,7 +51,7 @@ async function main() { // Process each file in parallel const results = await Promise.allSettled( - files.map(async (entry) => processFile(entry)), + files.map(async (entry) => processFile(entry)) ); results.forEach((result) => {