Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vue-router/src/Matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare module '@tanstack/router-core' {
meta?: Array<Vue.ComponentOptions['meta'] | undefined>
links?: Array<Vue.ComponentOptions['link'] | undefined>
scripts?: Array<Vue.ComponentOptions['script'] | undefined>
styles?: Array<Vue.ComponentOptions['style'] | undefined>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
headScripts?: Array<Vue.ComponentOptions['script'] | undefined>
}
}
Expand Down
16 changes: 16 additions & 0 deletions packages/vue-router/src/headContentUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
return preloadMeta
})

const styles = Vue.computed<Array<RouterManagedTag>>(() =>
(
matches.value
.map((match) => match.styles!)
.flat(1)
.filter(Boolean) as Array<RouterManagedTag>
).map(({ children, ...style }) => ({
tag: 'style',
attrs: {
...style,
},
children,
})),
)

const headScripts = Vue.computed<Array<RouterManagedTag>>(() =>
(
matches.value
Expand Down Expand Up @@ -182,6 +197,7 @@ export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
...meta.value,
...preloadMeta.value,
...links.value,
...styles.value,
...headScripts.value,
] as Array<RouterManagedTag>,
(d) => {
Expand Down