mirror of
https://codeberg.org/teddit/teddit.git
synced 2026-04-18 21:45:06 -04:00
#51 update theme with url query parameter.
Also fixed a nested comment alternating style issue
This commit is contained in:
@@ -93,6 +93,21 @@ if(config.use_compression) {
|
||||
|
||||
app.use(cookieParser())
|
||||
|
||||
const themeMiddleware = (req, res, next) => {
|
||||
let themeOverride = req.query.theme
|
||||
if( themeOverride) {
|
||||
// Convert Dark to dark since the stylesheet has it lower case
|
||||
themeOverride = themeOverride.toLowerCase();
|
||||
// This override here will set it for the current request
|
||||
req.cookies.theme = themeOverride
|
||||
// this will set it for future requests
|
||||
res.cookie('theme', themeOverride, {maxAge: 31536000, httpOnly: true})
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
app.use(themeMiddleware)
|
||||
|
||||
if(config.use_view_cache) {
|
||||
app.set('view cache', true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user