Skip to content

Commit

Permalink
feat(guideItem): Adds guide item schema mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mschinis authored and sivakumar-kailasam committed Aug 12, 2018
1 parent e650be4 commit e77749f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/schemas/guideItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Takes a version, parent (lvl0) and a "guide item" object and transforms it to the payload that needs to be stored in algolia
* @param {Object} version - Ember version string
* @param {Object} parent - Parent object to be used for lvl0 hierarchy
* @param {Object} item - The object to transform
* @returns {Object}
*/
export default function guideItemSchema(version, parent, item) {
// console.log('item', item);
const skipTocTag = item['skip-toc']? `skipTOC:true` : `skipTOC:false`;

return {
title: item.title,
id: item.id,
url: item.url,
content: item.attributes.content,
description: item.attributes.description,

_tags: [
`version:${version}`,
skipTocTag
],

hierarchy: {
lvl0: parent.title,
lvl1: item.title
}
};
}
4 changes: 3 additions & 1 deletion src/schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import classSchema from './class';
import moduleSchema from './module';
import methodSchema from './method';
import guideItemSchema from './guideItem';

export default {
moduleSchema,
classSchema,
methodSchema
methodSchema,
guideItemSchema
};

0 comments on commit e77749f

Please sign in to comment.