all: Aggiunte varie feature e riscritte svariate cose
This commit is contained in:
@@ -52,23 +52,14 @@ async function createDevRouter() {
|
||||
|
||||
const { html, metadata } = render(req.originalUrl)
|
||||
|
||||
process.stdout.write('[Metadata] ')
|
||||
console.dir(metadata)
|
||||
|
||||
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
|
||||
const metaTagsHtml =
|
||||
'' +
|
||||
(metadata.title ? `<meta property="og:title" content="${metadata.title}" />\n` : '') +
|
||||
(metadata.description
|
||||
? `<meta property="og:description" content="${metadata.description}" />\n`
|
||||
: '') +
|
||||
(metadata.description ? `<meta property="og:description" content="${metadata.description}" />\n` : '') +
|
||||
`<meta property="og:url" content="${fullUrl}" />\n`
|
||||
|
||||
res.send(
|
||||
transformedTemplate
|
||||
.replace('<!-- INJECT META TAGS -->', metaTagsHtml)
|
||||
.replace('<!-- SSR OUTLET -->', html)
|
||||
)
|
||||
res.send(transformedTemplate.replace('<!-- INJECT META TAGS -->', metaTagsHtml).replace('<!-- SSR OUTLET -->', html))
|
||||
} catch (error: any) {
|
||||
vite.ssrFixStacktrace(error)
|
||||
next(error)
|
||||
@@ -95,23 +86,14 @@ async function createProductionRouter() {
|
||||
|
||||
const { html, metadata } = render(req.originalUrl)
|
||||
|
||||
process.stdout.write('[Metadata] ')
|
||||
console.dir(metadata)
|
||||
|
||||
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
|
||||
const metaTagsHtml =
|
||||
'' +
|
||||
(metadata.title ? `<meta property="og:title" content="${metadata.title}" />\n` : '') +
|
||||
(metadata.description
|
||||
? `<meta property="og:description" content="${metadata.description}" />\n`
|
||||
: '') +
|
||||
(metadata.description ? `<meta property="og:description" content="${metadata.description}" />\n` : '') +
|
||||
`<meta property="og:url" content="${fullUrl}" />\n`
|
||||
|
||||
res.send(
|
||||
transformedTemplate
|
||||
.replace('<!-- INJECT META TAGS -->', metaTagsHtml)
|
||||
.replace('<!-- SSR OUTLET -->', html)
|
||||
)
|
||||
res.send(transformedTemplate.replace('<!-- INJECT META TAGS -->', metaTagsHtml).replace('<!-- SSR OUTLET -->', html))
|
||||
})
|
||||
|
||||
r.use('/', express.static('dist/entry-client'))
|
||||
@@ -126,7 +108,7 @@ async function createProductionRouter() {
|
||||
async function main() {
|
||||
const app = express()
|
||||
|
||||
app.use(morgan('dev'))
|
||||
app.use(morgan('[Request] :method :url :status :response-time ms - :res[content-length]'))
|
||||
|
||||
app.use('/', await createApiRouter())
|
||||
|
||||
@@ -137,7 +119,7 @@ async function main() {
|
||||
}
|
||||
|
||||
app.listen(config.port, () => {
|
||||
console.log(`Listening on port ${config.port}...`)
|
||||
console.log(`[Server] Listening on port ${config.port}...`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user