@tanstack/react-router 1.123.2 → 1.124.0
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/dist/cjs/HeadContent.cjs +9 -0
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +1 -0
- package/dist/esm/HeadContent.js +9 -0
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Matches.d.ts +1 -0
- package/dist/esm/Matches.js.map +1 -1
- package/dist/llms/rules/guide.d.ts +1 -1
- package/dist/llms/rules/guide.js +10 -1
- package/package.json +2 -2
- package/src/HeadContent.tsx +16 -0
- package/src/Matches.tsx +1 -0
package/dist/llms/rules/guide.js
CHANGED
|
@@ -1892,7 +1892,7 @@ For full-stack applications that use Start, and even for single-page application
|
|
|
1892
1892
|
- Analytics
|
|
1893
1893
|
- CSS and JS loading/unloading
|
|
1894
1894
|
|
|
1895
|
-
To manage the document head, it's required that you render both the \`<HeadContent />\` and \`<Scripts />\` components and use the \`routeOptions.head\` property to manage the head of a route, which returns an object with \`title\`, \`meta\`, \`links\`, and \`scripts\` properties.
|
|
1895
|
+
To manage the document head, it's required that you render both the \`<HeadContent />\` and \`<Scripts />\` components and use the \`routeOptions.head\` property to manage the head of a route, which returns an object with \`title\`, \`meta\`, \`links\`, \`styles\`, and \`scripts\` properties.
|
|
1896
1896
|
|
|
1897
1897
|
## Managing the Document Head
|
|
1898
1898
|
|
|
@@ -1914,6 +1914,15 @@ export const Route = createRootRoute({
|
|
|
1914
1914
|
href: '/favicon.ico',
|
|
1915
1915
|
},
|
|
1916
1916
|
],
|
|
1917
|
+
styles: [
|
|
1918
|
+
{
|
|
1919
|
+
media: 'all and (max-width: 500px)',
|
|
1920
|
+
children: \`p {
|
|
1921
|
+
color: blue;
|
|
1922
|
+
background-color: yellow;
|
|
1923
|
+
}\`
|
|
1924
|
+
}
|
|
1925
|
+
]
|
|
1917
1926
|
scripts: [
|
|
1918
1927
|
{
|
|
1919
1928
|
src: 'https://www.google-analytics.com/analytics.js',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.124.0",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"tiny-warning": "^1.0.3",
|
|
82
82
|
"isbot": "^5.1.22",
|
|
83
83
|
"@tanstack/history": "1.121.34",
|
|
84
|
-
"@tanstack/router-core": "1.
|
|
84
|
+
"@tanstack/router-core": "1.124.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@testing-library/jest-dom": "^6.6.3",
|
package/src/HeadContent.tsx
CHANGED
|
@@ -120,6 +120,21 @@ export const useTags = () => {
|
|
|
120
120
|
structuralSharing: true as any,
|
|
121
121
|
})
|
|
122
122
|
|
|
123
|
+
const styles = useRouterState({
|
|
124
|
+
select: (state) =>
|
|
125
|
+
(
|
|
126
|
+
state.matches
|
|
127
|
+
.map((match) => match.styles!)
|
|
128
|
+
.flat(1)
|
|
129
|
+
.filter(Boolean) as Array<RouterManagedTag>
|
|
130
|
+
).map(({ children, ...attrs }) => ({
|
|
131
|
+
tag: 'style',
|
|
132
|
+
attrs,
|
|
133
|
+
children,
|
|
134
|
+
})),
|
|
135
|
+
structuralSharing: true as any,
|
|
136
|
+
})
|
|
137
|
+
|
|
123
138
|
const headScripts = useRouterState({
|
|
124
139
|
select: (state) =>
|
|
125
140
|
(
|
|
@@ -142,6 +157,7 @@ export const useTags = () => {
|
|
|
142
157
|
...meta,
|
|
143
158
|
...preloadMeta,
|
|
144
159
|
...links,
|
|
160
|
+
...styles,
|
|
145
161
|
...headScripts,
|
|
146
162
|
] as Array<RouterManagedTag>,
|
|
147
163
|
(d) => {
|
package/src/Matches.tsx
CHANGED
|
@@ -34,6 +34,7 @@ declare module '@tanstack/router-core' {
|
|
|
34
34
|
meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>
|
|
35
35
|
links?: Array<React.JSX.IntrinsicElements['link'] | undefined>
|
|
36
36
|
scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>
|
|
37
|
+
styles?: Array<React.JSX.IntrinsicElements['style'] | undefined>
|
|
37
38
|
headScripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>
|
|
38
39
|
}
|
|
39
40
|
}
|