on master help sign in
Now displays search results for all pages, not just /docs + misc design fixes
commitd09c7240e2fd0f29289d2a5cb6a0dfc0658ae30f authorfrancescanarea <francesca@narea.com> dateTue 2 Jul 2019, 13:54 (7 years ago) parent53dabcc
4 files changed+44−23
sass/_main.scss+14−15 static/scripts.js+28−6 templates/partials/navigation-docs.html+1−1 templates/partials/search-overlay.html+1−1
sass/_main.scss+14−15
@@ -299,6 +299,7 @@ iframe {
299299 .search-bar {
300300 padding: 0;
301301 border: none;
302+ //border-bottom:black;
302303 &__input {
303304 padding-left: 40px;
304305 border-left: none;
@@ -309,13 +310,16 @@ iframe {
309310 z-index: 1;
310311 }
311312 &:hover, &:active, &:focus {
312− border: none;
313+ border:none;
314+
313315 }
314316 input[type="search"] {
315317 &:hover, &:active, &:focus {
316318 border-left: none;
317319 border-top: none;
318320 border-right: none;
321+
322+
319323 }
320324 }
321325 &__input {
@@ -326,15 +330,13 @@ iframe {
326330
327331.search-results {
328332 max-height: 400px;
329− //&__item, &__item a,
330− &__header {
331− color: #B1B2B3;
332− }
333+ &__item, &__item a,
334+
333335 &__item {
334336 a {
335− text-decoration: none;
336− display: block;
337− padding: (3rem /4) (4rem / 4);
337+ //text-decoration: none;
338+ //display: block;
339+ //padding: (3rem /4) (4rem / 4);
338340 &:hover {
339341 background: #F9F9F9;
340342 &:before, &:after {
@@ -369,18 +371,15 @@ iframe {
369371 b {
370372 color: #000;
371373 }
372− &__title {
373− font-size: (6rem / 4);
374+ /*&__title {
375+ //font-size: (6rem / 4);
374376 text-transform: capitalize;
375377 &__slug-end {
376378 color: #000;
377379 font-weight: 700;
378380 padding-right: (8rem / 4);
379381 }
380− }
381− }
382− &__header {
383− padding: 0 (7rem / 4);
382+ }*/
384383 }
385384}
386385
@@ -462,7 +461,7 @@ button, .btn {
462461 height: 9px;
463462 }
464463 &:hover {
465− border: 1px solid #000000;
464+ border: 1px solid #7f7f7f;
466465 }
467466}
468467
static/scripts.js+28−6
@@ -137,6 +137,7 @@ function makeTeaser(body, terms) {
137137 var stemmedTerms = terms.map(function (w) {
138138 return elasticlunr.stemmer(w.toLowerCase());
139139 });
140+
140141 var termFound = false;
141142 var index = 0;
142143 var weighted = []; // contains elements of ["word", weight, index_in_document]
@@ -221,15 +222,15 @@ function makeTeaser(body, terms) {
221222 startIndex = word[2];
222223 }
223224
224− // add <em/> around search terms
225+ // add dark color around search terms
225226 if (word[1] === TERM_WEIGHT) {
226− teaser.push("<b>");
227+ teaser.push("<span class='gray70'>");
227228 }
228229 startIndex = word[2] + word[0].length;
229230 teaser.push(body.substring(word[2], startIndex));
230231
231232 if (word[1] === TERM_WEIGHT) {
232− teaser.push("</b>");
233+ teaser.push("</span>");
233234 }
234235 }
235236 teaser.push("…");
@@ -237,15 +238,35 @@ function makeTeaser(body, terms) {
237238}
238239
239240function formatSearchResultTitle(path) {
241+// console.log(path);
242+ var pathArray = path.split( '/' );
243+ //console.log(pathArray);
244+ /*var slug = pathArray[1];
245+// console.log(slug);
246+ var slugArray = slug.split( '/' );
247+ var lastPartTitle = slugArray.splice(slugArray.length - 2, slugArray.length).join('');
248+ var firstPartTitle = slugArray.join(' / ');
249+//console.log(lastPartTitle);
250+//console.log(firstPartTitle);
251+*/
252+ var firstPartTitle = pathArray[3]; // first directory is in 4th element of path array
253+ var lastPartTitle = pathArray[pathArray.length-2]; // last directory is in 2nd to last element of array
254+ var fullTitle = firstPartTitle + '<span class="gray90">' + ' / ' + lastPartTitle + '</span>';
255+ console.log(fullTitle);
256+ return fullTitle;
257+/*
240258 var pathArray = path.split( 'docs/' );
259+// console.log(pathArray);
241260 var slug = pathArray[1];
261+// console.log(slug);
242262 var slugArray = slug.split( '/' );
243263 var lastPartTitle = slugArray.splice(slugArray.length - 2, slugArray.length).join('');
244264 var firstPartTitle = slugArray.join(' / ');
245265
246− var fullTitle = firstPartTitle + ' / ' + '<span class="search-results__item__title__slug-end">' + lastPartTitle + '</span>';
266+ var fullTitle = firstPartTitle + '<span class="gray90">' + ' / ' + lastPartTitle + '</span>';
247267
248268 return fullTitle;
269+ */
249270}
250271
251272function formatSearchResultItem(item, terms) {
@@ -256,8 +277,9 @@ function formatSearchResultItem(item, terms) {
256277 li.classList.add("search-results__item");
257278 var hrefA = item.ref;
258279 createA.setAttribute('href', hrefA);
259− createA.innerHTML = `<span class="search-results__item__title">${teaserTitle}</span>`;
260− createA.innerHTML += `<div class="search-results__teaser">${makeTeaser(item.doc.body, terms)}</div>`;
280+ createA.setAttribute('class','no-underline block pl6 pv2');
281+ createA.innerHTML = `<span class="fs45 capitalize gray30">${teaserTitle}</span>`;
282+ createA.innerHTML += `<div class="fs35 gray30">${makeTeaser(item.doc.body, terms)}</div>`;
261283 return li;
262284}
263285
templates/partials/navigation-docs.html+1−1
@@ -7,7 +7,7 @@
77 {% set index = get_section(path="docs/_index.md") %}
88 {% for s in index.subsections %}
99 {% set subsection = get_section(path=s) %}
10− <li class="list__item content-nav__index__item">
10+ <li class="list__item content-nav__index__item mt5">
1111 <a class="text-600" href="{{ subsection.permalink }}">
1212 {{ subsection.title }}
1313 </a>
templates/partials/search-overlay.html+1−1
@@ -6,7 +6,7 @@
66 <input id="search" autocomplete="off" type="search" class="search-bar__input" placeholder="Go to...">
77 </div>
88 <div class="search-results">
9− <div class="search-results__header mb2"></div>
9+ <div class="search-results__header ml6 mv2 gray30 fs3"></div>
1010 <ul class="list search-results__items"></ul>
1111 </div>
1212 </div>