Skip to content

Commit

Permalink
fix(ts): Correct missing null checks in algolia.ts (#7369)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 10, 2023
1 parent 86fd9af commit 49379f6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/gatsby/utils/algolia.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env node */
/* eslint import/no-nodejs-modules:0 */

import fs from 'fs';
import {promises as fs} from 'fs';
import {join, resolve} from 'path';

import {
Expand Down Expand Up @@ -49,20 +49,21 @@ const flatten = async (pages: any[]) => {

const {context, path} = page;
const htmlFile = join(pub, path, 'index.html');
const html = (await fs.promises.readFile(htmlFile)).toString();
const html = (await fs.readFile(htmlFile)).toString();

// https://github.com/getsentry/sentry-global-search#algolia-record-stategy
let platforms = [];
let platforms: string[] = [];

if (context.platform) {
const {slug} = standardSDKSlug(context.platform.name);
const slug = standardSDKSlug(context.platform.name)?.slug;

let fullSlug = slug;

if (context.guide) {
const {slug: guideSlug} = standardSDKSlug(context.guide.name);
const guideSlug = standardSDKSlug(context.guide.name)?.slug;
fullSlug += `.${guideSlug}`;
}
platforms = extrapolate(fullSlug, '.');
platforms = extrapolate(fullSlug ?? 'generic', '.');
}

const newRecords = htmlToAlgoliaRecord(
Expand Down

1 comment on commit 49379f6

@vercel
Copy link

@vercel vercel bot commented on 49379f6 Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

docs.sentry.io
sentry-docs.sentry.dev
sentry-docs-git-master.sentry.dev

Please sign in to comment.