4d0783d9be
Use flush effects to custom apply css-in-js solution to app. Re-introduce flush effects to app-render, and remove default support of styled-jsx in `app/`. So that users will choose their own css-in-js solution if they need any customization. styled-jsx won't appear in client bundle if you didn't use it. For now we have to inject the initial styles before `</head>` to avoid hydration errors. Later on we can remove this once react can handle it. - [x] inject styles before end of head element - [x] add tests
20 lines
598 B
TypeScript
20 lines
598 B
TypeScript
import type { Segment } from '../../server/app-render'
|
|
|
|
export const matchSegment = (
|
|
existingSegment: Segment,
|
|
segment: Segment
|
|
): boolean => {
|
|
// Common case: segment is just a string
|
|
if (typeof existingSegment === 'string' && typeof segment === 'string') {
|
|
return existingSegment === segment
|
|
}
|
|
|
|
// Dynamic parameter case: segment is an array with param/value. Both param and value are compared.
|
|
if (Array.isArray(existingSegment) && Array.isArray(segment)) {
|
|
return (
|
|
existingSegment[0] === segment[0] && existingSegment[1] === segment[1]
|
|
)
|
|
}
|
|
|
|
return false
|
|
}
|