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
*************************/
@@ -189,6 +179,10 @@ app.post('/register', async (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,6 +1,10 @@
const express = require('express');
const app = express();
// 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
@@ -9,4 +13,6 @@ app.get('/league/:leagueName', (req, res) => {
// Render the league page template using Handlebars
res.render('partials/league-page/league-page', { leagueName: leagueName });
});
};