Greetings! I am new to working with Express and I am currently in the process of creating a portfolio website. In my project, I have a Pug file named project.pug which includes HTML content that should dynamically render based on the ID of each project stored in my JSON file:
"data": {
"projects": [
{
"id": "0",
"project_name": " ",
"description": " ",
"technologies": [ " "],
},
{
"id": "1",
"project_name": " ",
"description": " ",
"technologies": [ " "],
},
I am currently working on setting up a route where the URL contains an :id parameter to display content specific to each project's ID. For instance, if I visit http://localhost:8000/project/1, I expect to see details related to project 1. Similarly, by navigating to http://localhost:8000/project/2, information about project 2 should be displayed.
router.get('/project:id', (req, res) => {
res.render('project');
req.app.locals = data.projects.id;
const { id } = req.params //this variable represents the id of the project
const { side } = req.query; //this variable represents the page loaded with each project's info
However, I am facing challenges in implementing the JavaScript logic required to achieve this dynamic content rendering. Any assistance or guidance would be greatly appreciated!