I'm a beginner: just started learning server-side programming using nodejs. I have a blog site I developed with the help of Bootstrap. Now, I have index.js, welcome.ejs, header.ejs,and footer.ejs. No database yet; just working and learning the basics.
I can click on any "Continue reading" a-link in the welcome.ejs and the server (index.js) will take me to the blog.ejs.
welcome.ejs
`
Our latest...
...Common Mistake...
Nov 12
90% of marriage relationships today fail because of the ladies. Though
this result can be argued by many but,... "
index.js
app.get("/blogs",(req,res)=>{ res.render("blogs.ejs"); });
But, the problem is that other posts have the same "Continue reading" that link to the same blog.ejs; hence, I don't know how to determine the blog post/article to show in the blog.ejs when a "Continue reading" is clicked.
I tried to capture the of that post in welcome.ejs into the server (index.js) and use it to determine the blog post or article to route in the blog.ejs.
index.js
app.get("/blogs",(req,res)=>{ const blogPost=req.body["h3"].innerHTML; res.render("blogs.ejs", {postedBlog:blogPost}); });
Then in the blog.ejs, I tried to query the existence of the variable, postedBlog in index.js in order to know the right article to display in the blog.ejs.
blog.ejs
<% if (locals.postedBlog){%> <%= postedBlog%> <%} else{%> Firehose <%}%>