Skip to content

Commit

Permalink
fixed title
Browse files Browse the repository at this point in the history
  • Loading branch information
noam-honig committed Jul 10, 2023
1 parent 5a47d5e commit d680673
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions cfp-list
Submodule cfp-list added at b0ccd9
29 changes: 18 additions & 11 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ if (!process.env['VITE']) {
//app.use(helmet())
app.use(compression())
const frontendFiles = process.cwd() + '/dist'
const index = frontendFiles + '/index.html';
const index = frontendFiles + '/index.html'
app.get('/', (req, res) => {
const cfpId = req.query?.cfp;
const cfpId = req.query?.cfp
if (cfpId) {
api.withRemult(req, res, async () => {
const cfp = await cfpRepo.findId(cfpId! as string);
const cfp = await cfpRepo.findId(cfpId! as string)
if (cfp) {
res.send(fs.readFileSync(index).toString().replace("<!--TITLE-->", " - " + cfp.conferenceName).replace("<!--META-->",
`
res.send(
fs
.readFileSync(index)
.toString()
.replace('<!--TITLE-->', ' - ' + cfp.conferenceName)
.replace(
'<!--META-->',
`
<meta
name="description"
property="og:description"
Expand All @@ -35,21 +41,22 @@ property="og:image"
content="${cfp.image}"
/>
`
))

)
)
} else {
res.sendFile(index)
res.send(
fs.readFileSync(index).toString().replace('<!--TITLE-->', '')
)
}
})
return;
return
}

res.sendFile(index)
})
app.use(express.static(frontendFiles))
app.get('/*', (_, res) => {
res.sendFile(index)

res.send(fs.readFileSync(index).toString().replace('<!--TITLE-->', ''))
})
app.listen(process.env['PORT'] || 3001, () => console.log('Server started'))
}

0 comments on commit d680673

Please sign in to comment.