Skip to content

Commit 7993958

Browse files
committed
Add news to search
1 parent e868e31 commit 7993958

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

_includes/head.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
<div class="search-result">
2424
<a data-href="href"><h4 data-content="title"></h4></a>
2525
<span data-content="breadcrumbs" class="search-result-breadcrumbs"></span>
26-
<span data-content="author" class="search-result-author"></span>
26+
<span data-content="author" class="search-result-author"></span><br/>
27+
<span data-content="date" class="search-result-date"></span>
2728
</div>
2829
</script>
2930

_includes/header.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ <h2>In projects</h2>
5353
</div>
5454
</div>
5555

56+
<div class="search-results-container" id="search-results-news">
57+
<h2>In news</h2>
58+
<div data-content="news-results">
59+
<div class="no-results-note">No results</div>
60+
</div>
61+
</div>
62+
5663
<div class="search-results-container" id="search-results-misc">
5764
<h2>In other pages</h2>
5865
<div data-content="misc-results">

javascripts/search.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ var searchData;
66
var dataLoading = false;
77
var itemLoadTimer, searchKeystrokeEventTimer;
88

9-
var projectResultArea, docResultArea, miscResultArea;
9+
var projectResultArea, docResultArea, newsResultArea, miscResultArea;
1010
$(document).ready(function () {
1111
docResultArea = $('#search-results-docs > div');
1212
projectResultArea = $('#search-results-projects > div');
13+
newsResultArea = $('#search-results-news > div');
1314
miscResultArea = $('#search-results-misc > div');
1415

1516
var searchQuery = getQueryParam("search");
@@ -146,6 +147,7 @@ function doSearch(query) {
146147
//Clear existing results
147148
docResultArea.children('.search-result').remove();
148149
projectResultArea.children('.search-result').remove();
150+
newsResultArea.children('.search-result').remove();
149151
miscResultArea.children('.search-result').remove();
150152

151153
//Start the dropdown box's 'open' animation
@@ -164,6 +166,8 @@ function doSearch(query) {
164166
resultArea = docResultArea;
165167
else if(categoryTags.indexOf('projects') != -1)
166168
resultArea = projectResultArea;
169+
else if(categoryTags.indexOf('news') != -1)
170+
resultArea = newsResultArea;
167171

168172
resultArea.loadTemplate($('#search-result-template'), results[i], { append: true} );
169173

news/atom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: 'Atom news feed'
23
layout:
34
---
45
<?xml version="1.0"?>

search-index.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ layout:
77
"title" : "{{ post.title }}",
88
"href": "{{ site.github.url }}{{ post.url }}",
99
"author": "{{ post.author | join: ', ' }}",
10-
"date": {
11-
"day": "{{ post.date | date: "%d" }}",
12-
"month": "{{ post.date | date: "%B" }}",
13-
"year": "{{ post.date | date: "%Y" }}"
14-
},
10+
"date": "{{ post.date | date_to_long_string }}",
1511
"loopid" : "post-{{ forloop.index }}",
1612
"category": "{{ post.categories }}"
1713
},

0 commit comments

Comments
 (0)