Skip to content

Commit 18e9783

Browse files
committed
overall for 1.8
1 parent 1520c05 commit 18e9783

6 files changed

Lines changed: 96 additions & 109 deletions

File tree

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
Asynchronous SSR-ready Document Head management for Solid based on [React Head](https://github.com/tizmagik/react-head)
88

9+
> For Solid 1.8 use 0.29.x or greater.
910
> For Solid 1.0 use 0.27.x or greater.
1011
> For versions of Solid 0.x use 0.26.x.
1112
@@ -22,26 +23,23 @@ npm i @solidjs/meta
2223
## How it works
2324

2425
1. You wrap your App with `<MetaProvider />`
25-
1. From the server, you pass `tags[]` array to `<MetaProvider />`
26-
1. Then call `renderTags(tags)` and include in the `<head />` block of your server template
27-
1. To insert head tags within your app, just render one of `<Title />`, `<Meta />`, `<Style />`, `<Link />`, and `<Base />` components as often as needed.
26+
2. To insert head tags within your app, just render one of `<Title />`, `<Meta />`, `<Style />`, `<Link />`, and `<Base />` components as often as needed.
27+
3. One the server if you render the `<head>` element using SolidJS in JSX you are all good. Otherwise use `getAssets` from `solid-js/web` to insert the assets where you want.
2828

29-
On the server, the tags are collected in the `tags[]` array, and then on the client the server-generated tags are removed in favor of the client-rendered tags so that SPAs still work as expected (e.g. in cases where subsequent page loads need to change the head tags).
29+
On the server, the tags are collected, and then on the client the server-generated tags are removed in favor of the client-rendered tags so that SPAs still work as expected (e.g. in cases where subsequent page loads need to change the head tags).
3030

3131
### Server setup
3232

3333
Wrap your app with `<MetaProvider />` on the server, using a `tags[]` array to pass down as part of your server-rendered payload. When rendered, the component mutates this array to contain the tags.
3434

3535
```js
36-
import { renderToString } from 'solid-js/web';
37-
import { MetaProvider, renderTags } from '@solidjs/meta';
36+
import { renderToString, getAssets } from 'solid-js/web';
37+
import { MetaProvider } from '@solidjs/meta';
3838
import App from './App';
3939

4040
// ... within the context of a request ...
41-
42-
const tags = []; // mutated during render so you can include in server-rendered template later
4341
const app = renderToString(() =>
44-
<MetaProvider tags={tags}>
42+
<MetaProvider>
4543
<App />
4644
</MetaProvider>
4745
);
@@ -50,7 +48,7 @@ res.send(`
5048
<!doctype html>
5149
<html>
5250
<head>
53-
${renderTags(tags)}
51+
${getAssets()}
5452
</head>
5553
<body>
5654
<div id="root">${app}</div>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
"test:types": "tsc --project tsconfig.test.json"
3333
},
3434
"peerDependencies": {
35-
"solid-js": ">=1.4.0"
35+
"solid-js": ">=1.8.4"
3636
},
3737
"devDependencies": {
3838
"@babel/cli": "^7.14.3",
3939
"@babel/core": "7.14.3",
4040
"@babel/preset-env": "7.14.4",
4141
"@babel/preset-typescript": "7.13.0",
4242
"@types/jest": "^26.0.23",
43-
"babel-preset-solid": "^1.7.0",
43+
"babel-preset-solid": "^1.8.4",
4444
"jest": "^26.6.3",
4545
"rimraf": "^3.0.2",
4646
"solid-jest": "0.1.1",
47-
"solid-js": "^1.7.0",
47+
"solid-js": "^1.8.4",
4848
"typescript": "4.9.4"
4949
},
5050
"jest": {

pnpm-lock.yaml

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)