all: Aggiunte varie feature e riscritte svariate cose

This commit is contained in:
2022-12-01 03:45:29 +01:00
parent bd055f484d
commit 8fdef2981d
22 changed files with 714 additions and 422 deletions
+6 -24
View File
@@ -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}...`)
})
}