Skip to content

Commit

Permalink
Fixed header, latest-version relied on Node API's
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugos68 committed Jan 14, 2025
1 parent 74e12da commit 2dbd0fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 132 deletions.
119 changes: 0 additions & 119 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sites/floating-ui-svelte.vercel.app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"autoprefixer": "^10.4.20",
"focus-trap": "^7.6.2",
"latest-version": "^9.0.0",
"lucide-svelte": "^0.469.0",
"pagefind": "^1.3.0",
"shiki": "^1.24.4",
Expand Down
33 changes: 21 additions & 12 deletions sites/floating-ui-svelte.vercel.app/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { browser } from "$app/environment";
import getLatestVersion from "latest-version";
import type { Pagefind } from "vite-plugin-pagefind/types";

export async function load() {
const version = await getLatestVersion("@skeletonlabs/floating-ui-svelte");
if (browser) {
// @ts-expect-error - Dynamic import
const pagefind: Pagefind = await import("/pagefind/pagefind.js");
await pagefind.init();
return {
version,
pagefind,
};
async function getPageFind() {
if (!browser) {
return null;
}
// @ts-expect-error - File will be generated at build time
const pagefind: Pagefind = await import("/pagefind/pagefind.js");
await pagefind.init();
return pagefind;
}

async function getLatestVersion(fetcher: typeof fetch) {
const response = await fetcher("https://registry.npmjs.org/@skeletonlabs/floating-ui-svelte");
const data = await response.json();
const version = data["dist-tags"].latest;
return version;
}

export async function load({ fetch }) {
const version = getLatestVersion(fetch);
const pagefind = await getPageFind();
return {
version,
version: version,
pagefind: pagefind
};
}

Expand Down

0 comments on commit 2dbd0fa

Please sign in to comment.