added backend search functionality
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
+23
-3
@@ -116,6 +116,25 @@ function createLargePost(post)
|
||||
*/
|
||||
function loadHomeContent()
|
||||
{
|
||||
let menuBar = document.createElement('div');
|
||||
menuBar.classList.add('menuBar');
|
||||
// language=HTML
|
||||
menuBar.innerHTML = `
|
||||
<div class="menu">
|
||||
<ul>
|
||||
<li><a href="/blog/category" class="link">categories</a></li>
|
||||
<li>
|
||||
<label for="search" aria-hidden="true" hidden>search</label>
|
||||
<input type="search" name="search" id="search"
|
||||
placeholder="Search...">
|
||||
<button type="submit" class="btn btnPrimary"><i
|
||||
class="fa fa-search"></i></button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
`;
|
||||
document.querySelector('#main').appendChild(menuBar);
|
||||
|
||||
fetch('/api/blog/post').then(res => res.json().then(json =>
|
||||
{
|
||||
for (let i = 0; i < json.length; i++)
|
||||
@@ -130,10 +149,10 @@ function loadHomeContent()
|
||||
featuredPost.appendChild(h1);
|
||||
let outerContent = createLargePost(json[i]);
|
||||
featuredPost.appendChild(outerContent);
|
||||
document.querySelector('#main').prepend(featuredPost);
|
||||
document.querySelector('#main').appendChild(featuredPost);
|
||||
}
|
||||
|
||||
if (i === 0)
|
||||
if (i === 1)
|
||||
{
|
||||
let latestPost = document.createElement('section');
|
||||
latestPost.classList.add('largePost');
|
||||
@@ -143,8 +162,9 @@ function loadHomeContent()
|
||||
latestPost.appendChild(h1);
|
||||
let outerContent = createLargePost(json[i]);
|
||||
latestPost.appendChild(outerContent);
|
||||
document.querySelector('#main').prepend(latestPost);
|
||||
document.querySelector('#main').appendChild(latestPost);
|
||||
}
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user