// routes/front.js
import express from 'express'
const frontRouter = express.Router()
import homeRouter from './front/home.js'
frontRouter.use('/',homeRouter)
import loginRouter from './front/login.js'
frontRouter.use('/login',loginRouter)
export default frontRouter
// routes/front/login.js
import express from "express"
const loginRouter = express.Router()
import login from '../../controllers/front/login.js'
loginRouter.get('/',async (req,res)=>{
if(req.session.user){
res.redirect('/admin/post')
}else{
login.getItem(req,res)
}
})
export default loginRouter
// controllers/front/login.js
import config from "../../config.js"
class Login{
async getItem(req,res){
this.config = await config()
this.config.pageTitle = 'ទំព័រចុះឈ្មោះចូលក្នុង'
this.config.route = '/login'
res.render('base',{data:this.config})
}
}
export default new Login()
<!--views/base.ejs-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title><%= data.siteTitle %> | <%= data.pageTitle %></title>
<link href="/images/siteLogo.png" rel="icon" />
<link href="/styles/base.css" rel="stylesheet" />
<link href="/fonts/setup.css" rel="stylesheet" />
<script src="/scripts/jquery.js"></script>
</head>
<body>
</body>
</html>
/* static/styles/base.css */
:root{
--background-light: #dcf9c6;
--background: #88d498;
--background-dark: #155f4b;
--body-font: 14px/1.5 Vidaloka, OdorMeanChey;
--link: #1a936f;
--color: white;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
a{
text-decoration: none;
color: var(--link);
}
a:hover{
opacity: .7;
}
.region{
max-width: 1100px;
margin: 0 auto;
}
body{
color: var(--color);
font: var(--body-font);
background: var(--background-light);
}