blob: 1566bc619b1f6822959fe0ec6ca091a26462f495 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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') %>
|