mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-01-05 23:59:09 +00:00
feat(website): add exports to sidebar
This commit is contained in:
parent
f6a3cdd4b2
commit
b01384807a
5 changed files with 55 additions and 26 deletions
|
@ -8,7 +8,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await codeToHtml(code, { theme: 'vesper', lang, transformers: [{ pre(node) {
|
{#await codeToHtml(code, { theme: 'vesper', lang, transformers: [{ pre(node) {
|
||||||
this.addClassToHast(node, 'not-prose overflow-x-auto');
|
this.addClassToHast(node, 'not-prose overflow-x-auto px-4 py-2 rounded-md');
|
||||||
} }] }) then highlightedCode}
|
} }] }) then highlightedCode}
|
||||||
{@html highlightedCode}
|
{@html highlightedCode}
|
||||||
{/await}
|
{/await}
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col px-8 lg:px-16 py-4 gap-8 items-center lg:*:max-w-6xl">
|
<div class="flex flex-col px-8 lg:px-16 py-4 gap-12 items-center lg:*:max-w-6xl">
|
||||||
<header
|
<header
|
||||||
class="flex-0 flex flex-col lg:flex-row relative items-center gap-4 lg:gap-0 min-h-12 w-full"
|
class="flex-0 flex flex-col lg:flex-row relative items-center gap-4 lg:gap-0 min-h-12 w-full"
|
||||||
>
|
>
|
||||||
|
|
|
@ -24,10 +24,7 @@
|
||||||
<Note>
|
<Note>
|
||||||
If you are using pesde with the `wally` feature enabled (true on releases from the GitHub
|
If you are using pesde with the `wally` feature enabled (true on releases from the GitHub
|
||||||
repository) then you can use <Codeblock code="pesde convert" /> to convert your wally.toml file
|
repository) then you can use <Codeblock code="pesde convert" /> to convert your wally.toml file
|
||||||
to pesde.yaml. This will leave you with an empty default index, so you will need to add a URL (such
|
to pesde.yaml.
|
||||||
as the default `<a href="https://github.com/daimond113/pesde-index"
|
|
||||||
>https://github.com/daimond113/pesde-index</a
|
|
||||||
>`) yourself.
|
|
||||||
</Note>
|
</Note>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
import ChevronDown from 'lucide-svelte/icons/chevron-down';
|
import ChevronDown from 'lucide-svelte/icons/chevron-down';
|
||||||
import Mail from 'lucide-svelte/icons/mail';
|
import Mail from 'lucide-svelte/icons/mail';
|
||||||
import Globe from 'lucide-svelte/icons/globe';
|
import Globe from 'lucide-svelte/icons/globe';
|
||||||
|
import Check from 'lucide-svelte/icons/check';
|
||||||
|
import X from 'lucide-svelte/icons/x';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
|
||||||
|
@ -38,20 +40,10 @@
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
const parseAuthor = (author: string) => {
|
|
||||||
const authorRegex =
|
|
||||||
/^(?<name>.+?)(?:\s*<(?<email>.+?)>)?(?:\s*\((?<url>.+?)\))?(?:\s*<(?<email2>.+?)>)?(?:\s*\((?<url2>.+?)\))?$/;
|
|
||||||
const { groups } = author.match(authorRegex) ?? {};
|
|
||||||
return {
|
|
||||||
name: groups?.name ?? author,
|
|
||||||
email: groups?.email ?? groups?.email2,
|
|
||||||
url: groups?.url ?? groups?.url2
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
$: publishedAt = new Date(
|
$: publishedAt = new Date(
|
||||||
(data.versions.find(([version]) => version === data.version)?.[1] ?? 0) * 1000
|
(data.versions.find(([version]) => version === data.version)?.[1] ?? 0) * 1000
|
||||||
);
|
);
|
||||||
|
|
||||||
$: allDependencies = [
|
$: allDependencies = [
|
||||||
[data.dependencies, 'Dependencies'],
|
[data.dependencies, 'Dependencies'],
|
||||||
[data.peerDependencies, 'Peer Dependencies']
|
[data.peerDependencies, 'Peer Dependencies']
|
||||||
|
@ -131,19 +123,18 @@
|
||||||
<div class="section-title">Authors</div>
|
<div class="section-title">Authors</div>
|
||||||
<ul class="not-prose">
|
<ul class="not-prose">
|
||||||
{#each data.authors as author}
|
{#each data.authors as author}
|
||||||
{@const parsedAuthor = parseAuthor(author)}
|
|
||||||
<li class="flex">
|
<li class="flex">
|
||||||
<span class="overflow-text pr-2">
|
<span class="overflow-text pr-2">
|
||||||
{parsedAuthor.name}
|
{author.name}
|
||||||
</span>
|
</span>
|
||||||
<div class="ml-auto flex items-center gap-4">
|
<div class="ml-auto flex items-center gap-4">
|
||||||
{#if parsedAuthor.email}
|
{#if author.email}
|
||||||
<a href="mailto:{parsedAuthor.email}" title="Email {parsedAuthor.name}">
|
<a href="mailto:{author.email}" title="Email {author.name}">
|
||||||
<Mail class="size-6" />
|
<Mail class="size-6" />
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if parsedAuthor.url}
|
{#if author.url}
|
||||||
<a href={parsedAuthor.url} title="Website of {parsedAuthor.name}">
|
<a href={author.url} title="Website of {author.name}">
|
||||||
<Globe class="size-6" />
|
<Globe class="size-6" />
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -160,7 +151,7 @@
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
{#each allDependencies as [dependencies, title]}
|
{#each allDependencies as [dependencies, title]}
|
||||||
{#if dependencies}
|
{#if dependencies && dependencies.length > 0}
|
||||||
<section>
|
<section>
|
||||||
<div class="section-title">{title}</div>
|
<div class="section-title">{title}</div>
|
||||||
<ul class="not-prose">
|
<ul class="not-prose">
|
||||||
|
@ -188,6 +179,31 @@
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
<section>
|
||||||
|
<div class="section-title">Exports</div>
|
||||||
|
<ul class="not-prose">
|
||||||
|
<li>
|
||||||
|
<div class="flex items-center">
|
||||||
|
Library:
|
||||||
|
{#if data.exports.lib}
|
||||||
|
<Check class="size-6 text-green-500 inline-block ml-auto" />
|
||||||
|
{:else}
|
||||||
|
<X class="size-6 text-red-500 inline-block ml-auto" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<div class="flex items-center">
|
||||||
|
Binary:
|
||||||
|
{#if data.exports.bin}
|
||||||
|
<Check class="size-6 text-green-500 inline-block ml-auto" />
|
||||||
|
{:else}
|
||||||
|
<X class="size-6 text-red-500 inline-block ml-auto" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,6 +8,17 @@ export const ssr = false;
|
||||||
|
|
||||||
type Dependencies = ({ name: string; version: string } | { repo: string; rev: string })[];
|
type Dependencies = ({ name: string; version: string } | { repo: string; rev: string })[];
|
||||||
|
|
||||||
|
const parseAuthor = (author: string) => {
|
||||||
|
const authorRegex =
|
||||||
|
/^(?<name>.+?)(?:\s*<(?<email>.+?)>)?(?:\s*\((?<url>.+?)\))?(?:\s*<(?<email2>.+?)>)?(?:\s*\((?<url2>.+?)\))?$/;
|
||||||
|
const { groups } = author.match(authorRegex) ?? {};
|
||||||
|
return {
|
||||||
|
name: groups?.name ?? author,
|
||||||
|
email: groups?.email ?? groups?.email2,
|
||||||
|
url: groups?.url ?? groups?.url2
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params, fetch }) => {
|
export const load: PageLoad = async ({ params, fetch }) => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${import.meta.env.VITE_API_URL}/v0/packages/${params.scope}/${params.name}/${params.version}`
|
`${import.meta.env.VITE_API_URL}/v0/packages/${params.scope}/${params.name}/${params.version}`
|
||||||
|
@ -79,6 +90,7 @@ export const load: PageLoad = async ({ params, fetch }) => {
|
||||||
realm?: string;
|
realm?: string;
|
||||||
dependencies?: Dependencies;
|
dependencies?: Dependencies;
|
||||||
peer_dependencies?: Dependencies;
|
peer_dependencies?: Dependencies;
|
||||||
|
exports?: { lib?: string; bin?: string };
|
||||||
};
|
};
|
||||||
|
|
||||||
if (params.version.toLowerCase() === 'latest') {
|
if (params.version.toLowerCase() === 'latest') {
|
||||||
|
@ -102,13 +114,17 @@ export const load: PageLoad = async ({ params, fetch }) => {
|
||||||
name: params.name,
|
name: params.name,
|
||||||
version: parsed.version,
|
version: parsed.version,
|
||||||
versions,
|
versions,
|
||||||
authors: parsed.authors,
|
authors: parsed.authors?.map(parseAuthor),
|
||||||
description: parsed.description,
|
description: parsed.description,
|
||||||
license: parsed.license,
|
license: parsed.license,
|
||||||
readme,
|
readme,
|
||||||
repository: parsed.repository,
|
repository: parsed.repository,
|
||||||
realm: parsed.realm,
|
realm: parsed.realm,
|
||||||
dependencies: parsed.dependencies,
|
dependencies: parsed.dependencies,
|
||||||
peerDependencies: parsed.peer_dependencies
|
peerDependencies: parsed.peer_dependencies,
|
||||||
|
exports: {
|
||||||
|
lib: !!parsed.exports?.lib,
|
||||||
|
bin: !!parsed.exports?.bin
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue