@@ -13,37 +13,36 @@ const APP_ID = "KNPXZI5B0M";
1313
1414function isTailwindPlusURL ( url : string ) {
1515 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+ ) ;
2020}
2121
2222function isExternalURL ( url : string ) {
23- if ( url . startsWith ( ' https://tailwindui.com' ) ) {
24- return false
23+ if ( url . startsWith ( " https://tailwindui.com" ) ) {
24+ return false ;
2525 }
2626
2727 return / ^ h t t p s ? : \/ \/ / . test ( url ) && ! url . startsWith ( window . location . origin ) ;
2828}
2929
3030function rewriteURL ( url : string ) {
31- if ( ! url . startsWith ( ' https://tailwindui.com' ) ) {
32- return url
31+ if ( ! url . startsWith ( " https://tailwindui.com" ) ) {
32+ return url ;
3333 }
3434
35- url = url . replace ( ' https://tailwindui.com/' , ' https://tailwindcss.com/plus/' )
35+ url = url . replace ( " https://tailwindui.com/" , " https://tailwindcss.com/plus/" ) ;
3636 // 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" ) ;
4242
43- return url
43+ return url ;
4444}
4545
46-
4746const SearchContext = createContext < any > ( { } ) ;
4847
4948export function SearchProvider ( { children } : React . PropsWithChildren ) {
@@ -157,20 +156,20 @@ export function SearchProvider({ children }: React.PropsWithChildren) {
157156 hitComponent = { Hit }
158157 transformItems = { ( items ) => {
159158 items = items . map ( ( item ) => {
160- item . url = rewriteURL ( item . url )
161- return item
162- } )
159+ item . url = rewriteURL ( item . url ) ;
160+ return item ;
161+ } ) ;
163162
164163 // TODO: Remove this once only new stuff is indexed
165164 items = items . filter ( ( item ) => {
166165 // Remove old prev-Tailwind plus search results
167166 // @ts -ignore
168167 if ( item . hierarchy ?. lvl0 === "Components" ) {
169- return false
168+ return false ;
170169 }
171170
172- return true
173- } )
171+ return true ;
172+ } ) ;
174173
175174 return items . map ( ( item , index ) => {
176175 // We transform the absolute URL into a relative URL to
@@ -195,11 +194,11 @@ export function SearchProvider({ children }: React.PropsWithChildren) {
195194
196195 if ( isTailwindUI && item . hierarchy . lvl0 === "UI Blocks" ) {
197196 if ( item . hierarchy ?. lvl0 ) {
198- item . hierarchy . lvl0 = "Components"
197+ item . hierarchy . lvl0 = "Components" ;
199198 }
200199
201200 if ( item . _highlightResult ?. hierarchy ?. lvl0 ?. value ) {
202- item . _highlightResult . hierarchy . lvl0 . value = "Components"
201+ item . _highlightResult . hierarchy . lvl0 . value = "Components" ;
203202 }
204203 }
205204
0 commit comments