From ab6369648d41813660f88f9da664c2e3743e536a Mon Sep 17 00:00:00 2001 From: Gael BOYENVAL Date: Fri, 16 Jun 2017 19:10:26 +0200 Subject: [PATCH] search(refactor): update dom and add logo --- _sass/objects/_search-bar.scss | 18 ++++++++++++++++++ img/Algolia_logo_bg-white.svg | 21 +++++++++++++++++++++ js/search.js | 30 +++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 img/Algolia_logo_bg-white.svg diff --git a/_sass/objects/_search-bar.scss b/_sass/objects/_search-bar.scss index 0cb86654e..7007bd629 100644 --- a/_sass/objects/_search-bar.scss +++ b/_sass/objects/_search-bar.scss @@ -53,3 +53,21 @@ } } } + + +.search-logo { + font-size: 1.3rem; + padding-bottom: 15px; + padding-top: 15px; + text-align: right; + + &-bg { + background: url('../img/Algolia_logo_bg-white.svg') no-repeat; + background-size: contain; + display: inline-block; + width: 70px; + height: 25px; + margin-bottom: -10px; + margin-left: 6px; + } +} diff --git a/img/Algolia_logo_bg-white.svg b/img/Algolia_logo_bg-white.svg new file mode 100644 index 000000000..64ce5dbc1 --- /dev/null +++ b/img/Algolia_logo_bg-white.svg @@ -0,0 +1,21 @@ + + + + Algolia_logo_bg-white + Created with Sketch. + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/search.js b/js/search.js index 2fc8bc3e0..8168fd98f 100644 --- a/js/search.js +++ b/js/search.js @@ -18,15 +18,43 @@ document.addEventListener("DOMContentLoaded", function(event) { index.search(searchInput.value, function(err, content) { var htmlArticle = ''; + Object.keys(content.hits).map(function(key){ var hit = content.hits[key]; + if (hit.type == 'document') { var date = new Date(hit.date); date = moment(date).format("MMMM DD, YYYY"); - htmlArticle += '

' + hit.title + '

' + date + '

' + hit.excerpt + 'Lire l\'article
'; + + htmlArticle += '
'; + htmlArticle += '
'; + htmlArticle += '

'; + htmlArticle += ' '; + htmlArticle += ' ' + hit.title; + htmlArticle += ' '; + htmlArticle += '

'; + htmlArticle += ' '; + htmlArticle += '

'; + htmlArticle += ' ' + hit.excerpt; + htmlArticle += '

'; + htmlArticle += ' '; + htmlArticle += ' Lire l\'article'; + htmlArticle += ' '; + htmlArticle += '
'; + htmlArticle += '
'; } }); + + htmlArticle += ''; + contentSearchId.innerHTML = htmlArticle; }); }