-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
172 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// TODO/next-major-release: remove this file/export | ||
console.warn( | ||
"[vike-solid][warning][deprecation] Replace `import vikeSolid from 'vike-solid'` with `import vikeSolid from 'vike-solid/config'` (typically in your /pages/+config.js)" | ||
); | ||
export { default } from "./+config.js"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import { dangerouslySkipEscape, escapeInject, stampPipe, version } from "vike/se | |
import { getHeadSetting } from "./getHeadSetting.js"; | ||
import { getPageElement } from "./getPageElement.js"; | ||
import type { OnRenderHtmlAsync } from "vike/types"; | ||
import { PageContextProvider } from "./PageContextProvider.js"; | ||
import { PageContextProvider } from "../hooks/usePageContext.js"; | ||
|
||
checkVikeVersion(); | ||
|
||
|
@@ -18,17 +18,17 @@ const onRenderHtml: OnRenderHtmlAsync = async ( | |
const lang = getHeadSetting("lang", pageContext) || "en"; | ||
|
||
const titleTag = !title ? "" : escapeInject`<title>${title}</title>`; | ||
const faviconTag = !favicon | ||
? "" | ||
: escapeInject`<link rel="icon" href="${favicon}" />`; | ||
const faviconTag = !favicon ? "" : escapeInject`<link rel="icon" href="${favicon}" />`; | ||
|
||
const Head = pageContext.config.Head || (() => <></>); | ||
const headHtml = renderToString(() => ( | ||
const head = renderToString(() => ( | ||
<PageContextProvider pageContext={pageContext}> | ||
<Head /> | ||
</PageContextProvider> | ||
)); | ||
|
||
const headHtml = dangerouslySkipEscape(head) | ||
|
||
type TPipe = (writable: { write: (v: string) => void }) => void; | ||
|
||
let pageView: string | ReturnType<typeof dangerouslySkipEscape> | TPipe = ""; | ||
|
@@ -48,29 +48,28 @@ const onRenderHtml: OnRenderHtmlAsync = async ( | |
<head> | ||
<meta charset="UTF-8" /> | ||
${titleTag} | ||
${dangerouslySkipEscape(headHtml)} | ||
${headHtml} | ||
${faviconTag} | ||
${dangerouslySkipEscape(generateHydrationScript())} | ||
</head> | ||
<body> | ||
<div id="page-view">${pageView}</div> | ||
<div id="root">${pageView}</div> | ||
</body> | ||
<!-- built with https://github.com/vikejs/vike-solid --> | ||
</html>`; | ||
|
||
return documentHtml; | ||
}; | ||
|
||
// We don't need this anymore starting from [email protected] which added the `require` setting. | ||
// TODO/eventually: remove this once <=0.4.172 versions become rare. | ||
function checkVikeVersion() { | ||
if (version) { | ||
const versionParts = version.split(".").map((s) => parseInt(s, 10)) as [ | ||
number, | ||
number, | ||
number | ||
]; | ||
if (versionParts[0] > 0) return; | ||
if (versionParts[1] > 4) return; | ||
if (versionParts[2] >= 147) return; | ||
const versionParts = version.split('.').map((s) => parseInt(s, 10)) as [number, number, number] | ||
if (versionParts[0] > 0) return | ||
if (versionParts[1] > 4) return | ||
if (versionParts[2] >= 173) return | ||
} | ||
throw new Error("Update Vike to 0.4.147 or above"); | ||
// We can leave it 0.4.173 until we entirely remove checkVikeVersion() (because starting [email protected] we use the new `require` setting). | ||
throw new Error('Update Vike to 0.4.173 or above') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export { ssrEffect } | ||
|
||
import type { ConfigEffect } from 'vike/types' | ||
|
||
function ssrEffect({ configDefinedAt, configValue }: Parameters<ConfigEffect>[0]): ReturnType<ConfigEffect> { | ||
if (typeof configValue !== 'boolean') throw new Error(`${configDefinedAt} should be a boolean`) | ||
return { | ||
meta: { | ||
Page: { | ||
env: { | ||
// Always load `Page` on the client-side. | ||
client: true, | ||
// When the SSR flag is false, we want to render the page only on the client-side. | ||
// We achieve this by loading `Page` only on the client-side: when onRenderHtml() | ||
// gets a `Page` value that is undefined it skip server-side rendering. | ||
server: configValue !== false | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.