Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
search(refactor): update dom and add logo
  • Loading branch information
gael-boyenval authored and eko committed Jun 23, 2017
1 parent 2e06331 commit ab63696
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
18 changes: 18 additions & 0 deletions _sass/objects/_search-bar.scss
Expand Up @@ -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;
}
}
21 changes: 21 additions & 0 deletions img/Algolia_logo_bg-white.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion js/search.js
Expand Up @@ -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 += '<div class="post-teaser"><header><h1><a class="post-link" href="' + hit.url + '">' + hit.title + '</a></h1><p class="meta">' + date + '</p></header><div class="excerpt">' + hit.excerpt + '<a class="button" href="' + hit.url + '">Lire l\'article</a></div></div>';

htmlArticle += '<div class="posts-teaser slice">';
htmlArticle += ' <div class="container">';
htmlArticle += ' <h2 class="posts-title">';
htmlArticle += ' <a class="no-link-style" href="' + hit.url + '">';
htmlArticle += ' ' + hit.title;
htmlArticle += ' </a>';
htmlArticle += ' </h2>';
htmlArticle += ' <time class="posts-date meta">';
htmlArticle += ' <span class="meta-content">';
htmlArticle += ' ' + date;
htmlArticle += ' </span>';
htmlArticle += ' </time>';
htmlArticle += ' <p class="excerpt">';
htmlArticle += ' ' + hit.excerpt;
htmlArticle += ' </p>';
htmlArticle += ' <a class="button" href="' + hit.url + '">';
htmlArticle += ' Lire l\'article';
htmlArticle += ' </a>';
htmlArticle += ' </div>';
htmlArticle += '</div>';
}
});


htmlArticle += '<div class="container search-logo">';
htmlArticle += ' powered by';
htmlArticle += ' <span class="search-logo-bg"></span>';
htmlArticle += '</div>';

contentSearchId.innerHTML = htmlArticle;
});
}
Expand Down

0 comments on commit ab63696

Please sign in to comment.