File tree Expand file tree Collapse file tree 3 files changed +21
-132
lines changed
sites/floating-ui-svelte.vercel.app Expand file tree Collapse file tree 3 files changed +21
-132
lines changed Original file line number Diff line number Diff line change 15
15
"@sveltejs/vite-plugin-svelte" : " ^5.0.3" ,
16
16
"autoprefixer" : " ^10.4.20" ,
17
17
"focus-trap" : " ^7.6.2" ,
18
- "latest-version" : " ^9.0.0" ,
19
18
"lucide-svelte" : " ^0.469.0" ,
20
19
"pagefind" : " ^1.3.0" ,
21
20
"shiki" : " ^1.24.4" ,
Original file line number Diff line number Diff line change 1
1
import { browser } from "$app/environment" ;
2
- import getLatestVersion from "latest-version" ;
3
2
import type { Pagefind } from "vite-plugin-pagefind/types" ;
4
3
5
- export async function load ( ) {
6
- const version = await getLatestVersion ( "@skeletonlabs/floating-ui-svelte" ) ;
7
- if ( browser ) {
8
- // @ts -expect-error - Dynamic import
9
- const pagefind : Pagefind = await import ( "/pagefind/pagefind.js" ) ;
10
- await pagefind . init ( ) ;
11
- return {
12
- version,
13
- pagefind,
14
- } ;
4
+ async function getPageFind ( ) {
5
+ if ( ! browser ) {
6
+ return null ;
15
7
}
8
+ // @ts -expect-error - File will be generated at build time
9
+ const pagefind : Pagefind = await import ( "/pagefind/pagefind.js" ) ;
10
+ await pagefind . init ( ) ;
11
+ return pagefind ;
12
+ }
13
+
14
+ async function getLatestVersion ( fetcher : typeof fetch ) {
15
+ const response = await fetcher ( "https://registry.npmjs.org/@skeletonlabs/floating-ui-svelte" ) ;
16
+ const data = await response . json ( ) ;
17
+ const version = data [ "dist-tags" ] . latest ;
18
+ return version ;
19
+ }
20
+
21
+ export async function load ( { fetch } ) {
22
+ const version = getLatestVersion ( fetch ) ;
23
+ const pagefind = await getPageFind ( ) ;
16
24
return {
17
- version,
25
+ version : version ,
26
+ pagefind : pagefind
18
27
} ;
19
28
}
20
29
You can’t perform that action at this time.
0 commit comments