-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(guideItem): Adds guide item schema mapping
- Loading branch information
1 parent
e650be4
commit e77749f
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |