diff options
Diffstat (limited to 'views/search/byTag.ejs')
-rw-r--r-- | views/search/byTag.ejs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/views/search/byTag.ejs b/views/search/byTag.ejs new file mode 100644 index 0000000..1566bc6 --- /dev/null +++ b/views/search/byTag.ejs @@ -0,0 +1,74 @@ +<%- include('../partials/header') %> + +<div class='content'> + <div class='leftie'> + <ul> + <% if(!currentUser) { %> + <li><a href='/search/all'>Search for blog posts</a></li> + <ul id='sub'> + <li><a href="/search/all"><em>All blog posts</em></a></li> + <li><a href="/search/tag"><em><strong>By title</strong></em></a></li> + <li><a href="#"><em>By category</em></a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</a></li> + <% } else { %> + <li><a href='/blog/<%= currentUser.username %>'>My Blog</a></li> + <li><a href='/blog/<%= currentUser.username %>/new'>Create a blog post</a></li> + <li><a href='/search/all'>Search for blog posts</a></li> + <ul id='sub'> + <li><a href="/search/all"><em>All blog posts</em></a></li> + <li><a href="/search/tag"><em><strong>By title</strong></em></a></li> + <li><a href="#">By category</a></li> + </ul> + <li><a href='/'>About</a></li> + <li><a href='/browsers'>Minimal broswers</a></li> + <% } %> + </ul> + </div> + <div class='rightie' id='rev'> + <% let type = ''; %> + <div id="result"> + <% posts.map((post) => { %> + <% if(post.tag === type) { %> + <div class='bpost'> + <h4><a href="/blog/<%= post.author.username %>/<%= post._id %>"><%= post.title %></a></h4> + <img src="<%= post.image %>" alt="..."> + <p><%- post.body.substring(0, 300) %>...</p> + </div> + <% } else { %> + <div></div> + <% } %> + <% }) %> + </div> + + <form id='fposts' action="/search/tag"> + <select name='tag' value='<%= type %>' onChange='setType()'> + <option value="life">Life</option> + <option value="science">Science</option> + <option value="music">Music</option> + <option value="cinema">Cinema</option> + <option value="travel">Travel</option> + </select> + <button type='submit' onclick="findPosts()">Search</button> + </form> + <h3>Posts by tag</h3> + </div> +</div> + +<script type="text/javascript"> + const setType = (event) => { + type = document.getElementsByName('tag'); + console.log(type); + }; + +</script> + +<script type="text/javascript"> + const findPosts = () => { + event.preventDefault(); + $('#').load(document.URL + ' #'); + }; +</script> + +<%- include('../partials/footer') %>
\ No newline at end of file |