@@ -13,37 +13,36 @@ const APP_ID = "KNPXZI5B0M";
13
13
14
14
function isTailwindPlusURL ( url : string ) {
15
15
return (
16
- url . startsWith ( ' https://tailwindui.com' ) ||
17
- url . startsWith ( ' https://tailwindcss.com/plus' ) ||
18
- url . startsWith ( ' /plus' )
19
- )
16
+ url . startsWith ( " https://tailwindui.com" ) ||
17
+ url . startsWith ( " https://tailwindcss.com/plus" ) ||
18
+ url . startsWith ( " /plus" )
19
+ ) ;
20
20
}
21
21
22
22
function isExternalURL ( url : string ) {
23
- if ( url . startsWith ( ' https://tailwindui.com' ) ) {
24
- return false
23
+ if ( url . startsWith ( " https://tailwindui.com" ) ) {
24
+ return false ;
25
25
}
26
26
27
27
return / ^ h t t p s ? : \/ \/ / . test ( url ) && ! url . startsWith ( window . location . origin ) ;
28
28
}
29
29
30
30
function rewriteURL ( url : string ) {
31
- if ( ! url . startsWith ( ' https://tailwindui.com' ) ) {
32
- return url
31
+ if ( ! url . startsWith ( " https://tailwindui.com" ) ) {
32
+ return url ;
33
33
}
34
34
35
- url = url . replace ( ' https://tailwindui.com/' , ' https://tailwindcss.com/plus/' )
35
+ url = url . replace ( " https://tailwindui.com/" , " https://tailwindcss.com/plus/" ) ;
36
36
// Temporary thing while `https://tailwindui.com/` is rewritten to /plus
37
- url = url . replace ( ' /plus/plus/' , ' /plus/' )
38
- url = url . replace ( ' /plus/components' , ' /plus/ui-blocks' )
39
- url = url . replace ( ' /plus/templates/catalyst' , ' /plus/ui-kit' )
40
- url = url . replace ( ' /plus/all-access' , ' /plus/#pricing' )
41
- url = url . replace ( ' /plus/documentation' , ' /plus/ui-blocks/documentation' )
37
+ url = url . replace ( " /plus/plus/" , " /plus/" ) ;
38
+ url = url . replace ( " /plus/components" , " /plus/ui-blocks" ) ;
39
+ url = url . replace ( " /plus/templates/catalyst" , " /plus/ui-kit" ) ;
40
+ url = url . replace ( " /plus/all-access" , " /plus/#pricing" ) ;
41
+ url = url . replace ( " /plus/documentation" , " /plus/ui-blocks/documentation" ) ;
42
42
43
- return url
43
+ return url ;
44
44
}
45
45
46
-
47
46
const SearchContext = createContext < any > ( { } ) ;
48
47
49
48
export function SearchProvider ( { children } : React . PropsWithChildren ) {
@@ -157,20 +156,20 @@ export function SearchProvider({ children }: React.PropsWithChildren) {
157
156
hitComponent = { Hit }
158
157
transformItems = { ( items ) => {
159
158
items = items . map ( ( item ) => {
160
- item . url = rewriteURL ( item . url )
161
- return item
162
- } )
159
+ item . url = rewriteURL ( item . url ) ;
160
+ return item ;
161
+ } ) ;
163
162
164
163
// TODO: Remove this once only new stuff is indexed
165
164
items = items . filter ( ( item ) => {
166
165
// Remove old prev-Tailwind plus search results
167
166
// @ts -ignore
168
167
if ( item . hierarchy ?. lvl0 === "Components" ) {
169
- return false
168
+ return false ;
170
169
}
171
170
172
- return true
173
- } )
171
+ return true ;
172
+ } ) ;
174
173
175
174
return items . map ( ( item , index ) => {
176
175
// We transform the absolute URL into a relative URL to
@@ -195,11 +194,11 @@ export function SearchProvider({ children }: React.PropsWithChildren) {
195
194
196
195
if ( isTailwindUI && item . hierarchy . lvl0 === "UI Blocks" ) {
197
196
if ( item . hierarchy ?. lvl0 ) {
198
- item . hierarchy . lvl0 = "Components"
197
+ item . hierarchy . lvl0 = "Components" ;
199
198
}
200
199
201
200
if ( item . _highlightResult ?. hierarchy ?. lvl0 ?. value ) {
202
- item . _highlightResult . hierarchy . lvl0 . value = "Components"
201
+ item . _highlightResult . hierarchy . lvl0 . value = "Components" ;
203
202
}
204
203
}
205
204
0 commit comments