Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

inlineCss.ts

31 lines807 Bytes

1import type { Awaitable } from '@tanstack/router-core'
2​
3export type HandlerInlineCssOption =
4 | boolean
5 | ((ctx: { request: Request }) => Awaitable<boolean>)
6​
7export function getStaticHandlerInlineCssDefault(
8 handlerInlineCss: HandlerInlineCssOption | undefined,
9) {
10 if (typeof handlerInlineCss === 'function') {
11 return undefined
12 }
13​
14 return handlerInlineCss ?? true
16​
17export async function resolveInlineCssForRequest(opts: {
18 request: Request
19 handlerInlineCss: HandlerInlineCssOption | undefined
20 requestInlineCss: boolean | undefined
21}) {
22 if (opts.requestInlineCss !== undefined) {
23 return opts.requestInlineCss
24 }
25​
26 if (typeof opts.handlerInlineCss === 'function') {
27 return await opts.handlerInlineCss({ request: opts.request })
28 }
29​
30 return opts.handlerInlineCss ?? true