Skip to content

Commit

Permalink
(fix): index pages with full slug (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Apr 28, 2024
1 parent fd9e96f commit 5b35afd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion servers/fdr/src/services/algolia/AlgoliaSearchRecordGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class NavigationContext {
public withPathParts(pathParts: PathPart[]) {
return new NavigationContext(this.#indexSegment, [...this.#pathParts, ...pathParts]);
}

/**
* @returns A new `NavigationContext` instance.
*/
public withFullSlug(fullSlug: string[]) {
return new NavigationContext(
this.#indexSegment,
fullSlug.map((urlSlug) => ({ name: urlSlug, urlSlug })),
);
}
}

interface AlgoliaSearchRecordGeneratorConfig {
Expand Down Expand Up @@ -225,7 +235,14 @@ export class AlgoliaSearchRecordGenerator {
if (pageContent == null) {
return [];
}
const pageContext = context.withPathPart({ name: page.title, urlSlug: page.urlSlug });

const pageContext =
page.fullSlug != null
? context.withFullSlug(page.fullSlug)
: context.withPathPart({
name: page.title,
urlSlug: page.urlSlug,
});
const processedContent = convertMarkdownToText(pageContent.markdown);
const { indexSegment } = context;
return [
Expand Down

0 comments on commit 5b35afd

Please sign in to comment.