Skip to content

Commit e77749f

Browse files
mschinissivakumar-kailasam
authored andcommitted
feat(guideItem): Adds guide item schema mapping
1 parent e650be4 commit e77749f

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/schemas/guideItem.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Takes a version, parent (lvl0) and a "guide item" object and transforms it to the payload that needs to be stored in algolia
3+
* @param {Object} version - Ember version string
4+
* @param {Object} parent - Parent object to be used for lvl0 hierarchy
5+
* @param {Object} item - The object to transform
6+
* @returns {Object}
7+
*/
8+
export default function guideItemSchema(version, parent, item) {
9+
// console.log('item', item);
10+
const skipTocTag = item['skip-toc']? `skipTOC:true` : `skipTOC:false`;
11+
12+
return {
13+
title: item.title,
14+
id: item.id,
15+
url: item.url,
16+
content: item.attributes.content,
17+
description: item.attributes.description,
18+
19+
_tags: [
20+
`version:${version}`,
21+
skipTocTag
22+
],
23+
24+
hierarchy: {
25+
lvl0: parent.title,
26+
lvl1: item.title
27+
}
28+
};
29+
}

src/schemas/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import classSchema from './class';
22
import moduleSchema from './module';
33
import methodSchema from './method';
4+
import guideItemSchema from './guideItem';
45

56
export default {
67
moduleSchema,
78
classSchema,
8-
methodSchema
9+
methodSchema,
10+
guideItemSchema
911
};

0 commit comments

Comments
 (0)