diff --git a/vike-solid/components/Config/Config-client.ts b/vike-solid/components/Config/Config-client.ts new file mode 100644 index 0000000..edb4074 --- /dev/null +++ b/vike-solid/components/Config/Config-client.ts @@ -0,0 +1,17 @@ +export { Config }; + +// Same as ./Config-server.ts but importing useConfig-client.js + +import { useConfig } from "../../hooks/useConfig/useConfig-client.js"; +import type { ConfigFromHook } from "../../types/Config.js"; + +/** + * Set configurations inside React components. + * + * https://vike.dev/useConfig + */ +function Config(props: ConfigFromHook): null { + const config = useConfig(); + config(props); + return null; +} diff --git a/vike-solid/components/Config/Config-server.ts b/vike-solid/components/Config/Config-server.ts new file mode 100644 index 0000000..b2f331d --- /dev/null +++ b/vike-solid/components/Config/Config-server.ts @@ -0,0 +1,17 @@ +export { Config }; + +// Same as ./Config-client.ts but importing useConfig-server.js + +import { useConfig } from "../../hooks/useConfig/useConfig-server.js"; +import type { ConfigFromHook } from "../../types/Config.js"; + +/** + * Set configurations inside React components. + * + * https://vike.dev/useConfig + */ +function Config(props: ConfigFromHook): null { + const config = useConfig(); + config(props); + return null; +} diff --git a/vike-solid/components/Head/Head-client.ts b/vike-solid/components/Head/Head-client.ts new file mode 100644 index 0000000..c715ff5 --- /dev/null +++ b/vike-solid/components/Head/Head-client.ts @@ -0,0 +1,19 @@ +export { Head }; + +// Same as ./Head-server.ts but importing useConfig-client.js + +import { useConfig } from "../../hooks/useConfig/useConfig-client.js"; +import type { JSX } from "solid-js/jsx-runtime"; + +/** + * Add arbitrary `` tags. + * + * (The children are teleported to ``.) + * + * https://vike.dev/Head + */ +function Head({ children }: { children: JSX.Element }): null { + const config = useConfig(); + config({ Head: children }); + return null; +} diff --git a/vike-solid/components/Head/Head-server.ts b/vike-solid/components/Head/Head-server.ts new file mode 100644 index 0000000..568db3b --- /dev/null +++ b/vike-solid/components/Head/Head-server.ts @@ -0,0 +1,19 @@ +export { Head }; + +// Same as ./Head-client.ts but importing useConfig-server.js + +import { useConfig } from "../../hooks/useConfig/useConfig-server.js"; +import type { JSX } from "solid-js/jsx-runtime"; + +/** + * Add arbitrary `` tags. + * + * (The children are teleported to ``.) + * + * https://vike.dev/Head + */ +function Head({ children }: { children: JSX.Element }): null { + const config = useConfig(); + config({ Head: children }); + return null; +} diff --git a/vike-solid/package.json b/vike-solid/package.json index 0774508..cb9793f 100644 --- a/vike-solid/package.json +++ b/vike-solid/package.json @@ -45,6 +45,14 @@ "browser": "./dist/hooks/useConfig/useConfig-client.js", "default": "./dist/hooks/useConfig/useConfig-server.js" }, + "./Config": { + "browser": "./dist/components/Config/Config-client.js", + "default": "./dist/components/Config/Config-server.js" + }, + "./Head": { + "browser": "./dist/components/Head/Head-client.js", + "default": "./dist/components/Head/Head-server.js" + }, "./clientOnly": "./dist/helpers/clientOnly.js", "./renderer/onRenderHtml": "./dist/renderer/onRenderHtml.js", "./renderer/onRenderClient": "./dist/renderer/onRenderClient.js", @@ -72,6 +80,12 @@ "useConfig": [ "dist/hooks/useConfig/useConfig-server.d.ts" ], + "Config": [ + "./dist/components/Config/Config-server.d.ts" + ], + "Head": [ + "./dist/components/Head/Head-server.d.ts" + ], "clientOnly": [ "dist/helpers/clientOnly.d.ts" ] diff --git a/vike-solid/rollup.config.js b/vike-solid/rollup.config.js index 0fe5c68..9c6ca68 100644 --- a/vike-solid/rollup.config.js +++ b/vike-solid/rollup.config.js @@ -11,6 +11,10 @@ export default [ "hooks/useData": "./hooks/useData.tsx", "hooks/useConfig/useConfig-client": "./hooks/useConfig/useConfig-client.ts", "hooks/useConfig/useConfig-server": "./hooks/useConfig/useConfig-server.ts", + "components/Config/Config-client": "./components/Config/Config-client.ts", + "components/Config/Config-server": "./components/Config/Config-server.ts", + "components/Head/Head-client": "./components/Head/Head-client.ts", + "components/Head/Head-server": "./components/Head/Head-server.ts", "helpers/clientOnly": "./helpers/clientOnly.tsx", }, ssr: true, @@ -23,6 +27,10 @@ export default [ "hooks/useData": "./hooks/useData.tsx", "hooks/useConfig/useConfig-client": "./hooks/useConfig/useConfig-client.ts", "hooks/useConfig/useConfig-server": "./hooks/useConfig/useConfig-server.ts", + "components/Config/Config-client": "./components/Config/Config-client.ts", + "components/Config/Config-server": "./components/Config/Config-server.ts", + "components/Head/Head-client": "./components/Head/Head-client.ts", + "components/Head/Head-server": "./components/Head/Head-server.ts", }, ssr: false, external: ["vike/server", "vike/plugin", "vike/getPageContext"], @@ -34,6 +42,10 @@ export default [ "./hooks/useData.tsx", "./hooks/useConfig/useConfig-client.ts", "./hooks/useConfig/useConfig-server.ts", + "./components/Config/Config-client.ts", + "./components/Config/Config-server.ts", + "./components/Head/Head-client.ts", + "./components/Head/Head-server.ts", "./helpers/clientOnly.tsx", "./vite-plugin-vike-solid.ts", ],