create-vike 0.0.360 → 0.0.362
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/boilerplate-react/package.json +1 -1
- package/boilerplate-react/renderer/+onRenderHtml.jsx +1 -1
- package/boilerplate-react/server/index.js +6 -11
- package/boilerplate-react-ts/package.json +1 -1
- package/boilerplate-react-ts/renderer/+onRenderHtml.tsx +1 -1
- package/boilerplate-react-ts/renderer/types.ts +2 -2
- package/boilerplate-react-ts/server/index.ts +6 -11
- package/boilerplate-vue/package.json +1 -1
- package/boilerplate-vue/server/index.js +6 -11
- package/boilerplate-vue-ts/package.json +1 -1
- package/boilerplate-vue-ts/renderer/types.ts +2 -2
- package/boilerplate-vue-ts/server/index.ts +6 -11
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ function onRenderHtml(pageContext) {
|
|
|
14
14
|
// onRenderHtml() to support SPA
|
|
15
15
|
if (!Page) throw new Error('My onRenderHtml() hook expects pageContext.Page to be defined')
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// Alternatively, we can use an HTML stream, see https://vike.dev/streaming
|
|
18
18
|
const pageHtml = ReactDOMServer.renderToString(
|
|
19
19
|
<Layout pageContext={pageContext}>
|
|
20
20
|
<Page />
|
|
@@ -50,7 +50,7 @@ async function startServer() {
|
|
|
50
50
|
|
|
51
51
|
// Vike middleware. It should always be our last middleware (because it's a
|
|
52
52
|
// catch-all middleware superseding any middleware placed after it).
|
|
53
|
-
app.get('*', async (req, res
|
|
53
|
+
app.get('*', async (req, res) => {
|
|
54
54
|
const pageContextInit = {
|
|
55
55
|
urlOriginal: req.originalUrl,
|
|
56
56
|
headersOriginal: req.headers
|
|
@@ -60,16 +60,11 @@ async function startServer() {
|
|
|
60
60
|
// Install error tracking here, see https://vike.dev/errors
|
|
61
61
|
}
|
|
62
62
|
const { httpResponse } = pageContext
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
69
|
-
res.status(statusCode)
|
|
70
|
-
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
71
|
-
res.send(body)
|
|
72
|
-
}
|
|
63
|
+
if (res.writeEarlyHints) res.writeEarlyHints({ link: httpResponse.earlyHints.map((e) => e.earlyHintLink) })
|
|
64
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
65
|
+
res.status(httpResponse.statusCode)
|
|
66
|
+
// For HTTP streams use pageContext.httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
67
|
+
res.send(httpResponse.body)
|
|
73
68
|
})
|
|
74
69
|
|
|
75
70
|
const port = process.env.PORT || 3000
|
|
@@ -15,7 +15,7 @@ const onRenderHtml: OnRenderHtmlAsync = async (pageContext): ReturnType<OnRender
|
|
|
15
15
|
// onRenderHtml() to support SPA
|
|
16
16
|
if (!Page) throw new Error('My onRenderHtml() hook expects pageContext.Page to be defined')
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// Alternatively, we can use an HTML stream, see https://vike.dev/streaming
|
|
19
19
|
const pageHtml = ReactDOMServer.renderToString(
|
|
20
20
|
<Layout pageContext={pageContext}>
|
|
21
21
|
<Page />
|
|
@@ -4,9 +4,9 @@ declare global {
|
|
|
4
4
|
interface PageContext {
|
|
5
5
|
Page: () => React.ReactElement
|
|
6
6
|
data?: {
|
|
7
|
-
/** Value for <title> defined
|
|
7
|
+
/** Value for <title> defined dynamically by by /pages/some-page/+data.js */
|
|
8
8
|
title?: string
|
|
9
|
-
/** Value for <meta name="description"> defined
|
|
9
|
+
/** Value for <meta name="description"> defined dynamically */
|
|
10
10
|
description?: string
|
|
11
11
|
}
|
|
12
12
|
config: {
|
|
@@ -50,7 +50,7 @@ async function startServer() {
|
|
|
50
50
|
|
|
51
51
|
// Vike middleware. It should always be our last middleware (because it's a
|
|
52
52
|
// catch-all middleware superseding any middleware placed after it).
|
|
53
|
-
app.get('*', async (req, res
|
|
53
|
+
app.get('*', async (req, res) => {
|
|
54
54
|
const pageContextInit = {
|
|
55
55
|
urlOriginal: req.originalUrl,
|
|
56
56
|
headersOriginal: req.headers
|
|
@@ -60,16 +60,11 @@ async function startServer() {
|
|
|
60
60
|
// Install error tracking here, see https://vike.dev/errors
|
|
61
61
|
}
|
|
62
62
|
const { httpResponse } = pageContext
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
69
|
-
res.status(statusCode)
|
|
70
|
-
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
71
|
-
res.send(body)
|
|
72
|
-
}
|
|
63
|
+
if (res.writeEarlyHints) res.writeEarlyHints({ link: httpResponse.earlyHints.map((e) => e.earlyHintLink) })
|
|
64
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
65
|
+
res.status(httpResponse.statusCode)
|
|
66
|
+
// For HTTP streams use pageContext.httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
67
|
+
res.send(httpResponse.body)
|
|
73
68
|
})
|
|
74
69
|
|
|
75
70
|
const port = process.env.PORT || 3000
|
|
@@ -50,7 +50,7 @@ async function startServer() {
|
|
|
50
50
|
|
|
51
51
|
// Vike middleware. It should always be our last middleware (because it's a
|
|
52
52
|
// catch-all middleware superseding any middleware placed after it).
|
|
53
|
-
app.get('*', async (req, res
|
|
53
|
+
app.get('*', async (req, res) => {
|
|
54
54
|
const pageContextInit = {
|
|
55
55
|
urlOriginal: req.originalUrl,
|
|
56
56
|
headersOriginal: req.headers
|
|
@@ -60,16 +60,11 @@ async function startServer() {
|
|
|
60
60
|
// Install error tracking here, see https://vike.dev/errors
|
|
61
61
|
}
|
|
62
62
|
const { httpResponse } = pageContext
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
69
|
-
res.status(statusCode)
|
|
70
|
-
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
71
|
-
res.send(body)
|
|
72
|
-
}
|
|
63
|
+
if (res.writeEarlyHints) res.writeEarlyHints({ link: httpResponse.earlyHints.map((e) => e.earlyHintLink) })
|
|
64
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
65
|
+
res.status(httpResponse.statusCode)
|
|
66
|
+
// For HTTP streams use pageContext.httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
67
|
+
res.send(httpResponse.body)
|
|
73
68
|
})
|
|
74
69
|
|
|
75
70
|
const port = process.env.PORT || 3000
|
|
@@ -11,9 +11,9 @@ declare global {
|
|
|
11
11
|
interface PageContext {
|
|
12
12
|
Page: Page
|
|
13
13
|
data?: {
|
|
14
|
-
/** Value for <title> defined
|
|
14
|
+
/** Value for <title> defined dynamically by by /pages/some-page/+data.js */
|
|
15
15
|
title?: string
|
|
16
|
-
/** Value for <meta name="description"> defined
|
|
16
|
+
/** Value for <meta name="description"> defined dynamically */
|
|
17
17
|
description?: string
|
|
18
18
|
}
|
|
19
19
|
config: {
|
|
@@ -50,7 +50,7 @@ async function startServer() {
|
|
|
50
50
|
|
|
51
51
|
// Vike middleware. It should always be our last middleware (because it's a
|
|
52
52
|
// catch-all middleware superseding any middleware placed after it).
|
|
53
|
-
app.get('*', async (req, res
|
|
53
|
+
app.get('*', async (req, res) => {
|
|
54
54
|
const pageContextInit = {
|
|
55
55
|
urlOriginal: req.originalUrl,
|
|
56
56
|
headersOriginal: req.headers
|
|
@@ -60,16 +60,11 @@ async function startServer() {
|
|
|
60
60
|
// Install error tracking here, see https://vike.dev/errors
|
|
61
61
|
}
|
|
62
62
|
const { httpResponse } = pageContext
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
69
|
-
res.status(statusCode)
|
|
70
|
-
// For HTTP streams use httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
71
|
-
res.send(body)
|
|
72
|
-
}
|
|
63
|
+
if (res.writeEarlyHints) res.writeEarlyHints({ link: httpResponse.earlyHints.map((e) => e.earlyHintLink) })
|
|
64
|
+
httpResponse.headers.forEach(([name, value]) => res.setHeader(name, value))
|
|
65
|
+
res.status(httpResponse.statusCode)
|
|
66
|
+
// For HTTP streams use pageContext.httpResponse.pipe() instead, see https://vike.dev/streaming
|
|
67
|
+
res.send(httpResponse.body)
|
|
73
68
|
})
|
|
74
69
|
|
|
75
70
|
const port = process.env.PORT || 3000
|