Skip to content

Commit bb5a0f8

Browse files
author
Kirill Bolotsky
authored
fix: algolia indexing (#154)
Put missing `slug` frontmatter field back into mdx entry processing pipeline References: #149 Dead link
1 parent 0c84503 commit bb5a0f8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/utils/algolia.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const processMdxEntry = ({ children: [entry] }) => {
1717
fileAbsolutePath,
1818
mdxAST,
1919
objectID,
20-
frontmatter: { title, redirect },
20+
frontmatter: { title, redirect, slug: customSlug },
2121
} = entry;
2222
if (redirect) {
2323
// avoid pushing empty records
@@ -41,13 +41,15 @@ const processMdxEntry = ({ children: [entry] }) => {
4141
.slice(0, -1)
4242
.join('/');
4343
const path = `/${cutStrippedDirectory}/${title.replace(/\//g, '-')}`;
44-
const slug = compose(
45-
noTrailingSlash,
46-
dedupePath,
47-
removeGuidesAndRedirectWelcome,
48-
unorderify,
49-
slugify,
50-
)(path);
44+
const slug =
45+
customSlug ||
46+
compose(
47+
noTrailingSlash,
48+
dedupePath,
49+
removeGuidesAndRedirectWelcome,
50+
unorderify,
51+
slugify,
52+
)(path);
5153
const chunks = chunk(mdxAstToPlainText(mdxAST), 300);
5254
let pointer = chunks.length;
5355
const cache = new Array(pointer);
@@ -86,6 +88,7 @@ const docPagesQuery = `{
8688
frontmatter {
8789
title
8890
redirect
91+
slug
8992
}
9093
mdxAST
9194
fileAbsolutePath

0 commit comments

Comments
 (0)