Skip to content

Tutorials links in algolia search #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/utils/algolia-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ const pageToAlgoliaRecordForASCII = (ele, type, node) => {
const numberOfChunks = len / 8000 + 1;
const chunks = splitStringIntoChunks(body, numberOfChunks);

// Code to deal with tutorials, which have pageId pattern of tutorialName__pageId
let finalLink = `/${config.SITE_PREFIX}/${pageid}`;
const pageIdSplit = pageid.split('__');
if (pageIdSplit.length > 1){
finalLink = `/${config.SITE_PREFIX}/tutorials/${pageIdSplit[0]}/${pageIdSplit[1]}`;
}

return chunks.map((chunk, i) => ({
objectID: `${sectionId}_chunk_${i}`,
sectionId,
Expand All @@ -106,7 +113,7 @@ const pageToAlgoliaRecordForASCII = (ele, type, node) => {
pageid,
type: 'ASCII',
title: node.document.title,
link: `/${config.SITE_PREFIX}/${pageid}`,
link: finalLink,
}));
};

Expand Down
Loading