I am created a simple blog post using tailwind and node.js. I made a header and a footer for my template now when I created a post.ejs page that renders dynamically and added a header and footer to the page the styles of tailwind doesn’t apply on the page.
app.get('/post/:topic', (req, res) => {
let topic = _.lowerCase(req.params.topic);
let matchfound = false;
if (posts.length === 0) {
res.status(404).send('<h1>No posts available</h1>');
return;
}
for (let i = 0; i < posts.length; i++) {
let eachpost = _.lowerCase(posts[i].title);
if (eachpost === topic) {
res.render('post', {
Title: posts[i].title,
page: posts[i].title,
paragraph: posts[i].content
});
matchfound = true;
break; // Exit the loop after finding a match
}
}
if (!matchfound) {
res.status(404).send('<h1>Post not found</h1>');
}
});
I Think the reason is when i try to get this dynamic parameter app.get(‘/post/:topic’, (req, res) => { because if i simply write /post the tailwind works correctly but then it will not create
This is my post.ejs page.
<%- include("partials/header"); -%>
<main>
<div class="heading">
<h1 class="text-3xl text-blue-700 m-5"><%= page %></h1>
</div>
<div class="para">
<p class="ml-8"><%= paragraph %></p>
</div>
</main>
<%- include("partials/footer"); -%>
I am expecting the header and footer to work correctly and apply tailwind classes.
Muhammad Umar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1