-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1452 from Nexmo/APIDOC-166_blog_search
APIDOC-166: Algolia BLOG search
- Loading branch information
Showing
11 changed files
with
209 additions
and
6 deletions.
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
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
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
33 changes: 33 additions & 0 deletions
33
lib/nexmo_developer/app/webpacker/javascript/components/search/Blog.vue
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,33 @@ | ||
<template> | ||
<div class='Nxd-search__result'> | ||
<a class='Nxd-search__result__link' v-bind:href='url' target='_blank'> | ||
<div> | ||
<h6 class='Vlt-blue-dark'>{{ title }}</h6> | ||
<p class='Nxd-search__result__highlight' v-html='snippet'></p> | ||
<span class='Vlt-badge Vlt-badge--grey Nxd-search__badge' :style="colorBadge">{{ badge }}</span> | ||
</div> | ||
</a> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
props: ['hit'], | ||
computed: { | ||
badge: function() { | ||
return this.hit.category.name; | ||
}, | ||
colorBadge: function() { | ||
return this.hit.category.color ? { background: this.hit.category.color } : { background: '#757575'} | ||
}, | ||
snippet: function() { | ||
return `...${this.hit._highlightResult.description.value}...`; | ||
}, | ||
title: function() { | ||
return this.hit.title; | ||
}, | ||
url: function() { | ||
return `https://developer.vonage.com/${this.hit.link}`; | ||
}, | ||
} | ||
} | ||
</script> |
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
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
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
28 changes: 28 additions & 0 deletions
28
lib/nexmo_developer/spec/javascript/components/search/Blog.test.js
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,28 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import Blog from 'components/search/Blog.vue'; | ||
|
||
describe('Blog', function() { | ||
const blog = { | ||
"title": "Vonage APIs rock!", | ||
"_snippetResult": { "description": { "value": "highlighted snippet" } }, | ||
"_highlightResult": { "description": { "value": "highlighted snippet" } }, | ||
"category": { "name": "Category name" }, | ||
"link": "1/2/3/latest_blog" | ||
}; | ||
|
||
it('renders the blog', function() { | ||
const wrapper = shallowMount(Blog, { propsData: { "hit": blog } }); | ||
|
||
expect(wrapper.find('.Nxd-search__result__link').attributes().href).toEqual( | ||
'https://developer.vonage.com/1/2/3/latest_blog' | ||
); | ||
|
||
expect(wrapper.find('h6.Vlt-blue-dark').text()).toEqual('Vonage APIs rock!'); | ||
|
||
expect(wrapper.find('.Nxd-search__result__highlight').text()).toEqual( | ||
'...highlighted snippet...' | ||
); | ||
|
||
expect(wrapper.find('.Nxd-search__badge').text()).toEqual('Category name'); | ||
}); | ||
}); |
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
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
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