League pages rendered

This commit is contained in:
Lucas Patenaude
2024-04-11 03:51:43 -06:00
parent 7588cf9fbb
commit 886d197fa7
2 changed files with 23 additions and 23 deletions

View File

@@ -91,16 +91,6 @@ app.use(fetchMatchesData);
const convert_time = require('./resources/js/navigation-bar/scoreboard-header/convert-time');
app.use(convert_time);
/************************
Homepage Routes
*************************/
/* const { app, redirectToLeaguePage } = require('ProjectSourceCode/src/resources/js/homepage/create-league-routes.js');
// Serve static files
app.use(express.static('public')); */
/************************
Login Page Routes
*************************/
@@ -181,13 +171,17 @@ app.post('/register', async (req, res) => {
});
/************************
/************************
Home Page Routes
*************************/
*************************/
app.get('/home', (req, res) => {
app.get('/home', (req, res) => {
res.render('pages/home');
});
});
// Import and call generateLeagueRoutes function
const generateLeagueRoutes = require('./resources/js/homepage/generate-league-routes');
generateLeagueRoutes(app);
// *****************************************************
// <!-- Section 5 : Start Server-->

View File

@@ -1,12 +1,18 @@
const express = require('express');
const app = express();
// Define a route to handle requests to "/league/:leagueName"
app.get('/league/:leagueName', (req, res) => {
// generate-league-routes.js
// Define a function to generate league routes
module.exports = function generateLeagueRoutes(app) {
// Define a route to handle requests to "/league/:leagueName"
app.get('/league/:leagueName', (req, res) => {
// Extract the league name from the URL parameters
const leagueName = req.params.leagueName;
// Render the league page template using Handlebars
res.render('partials/league-page/league-page', { leagueName: leagueName });
});
});
};