From b01384807a3b8c6adbb87396784a3781a9e2b53c Mon Sep 17 00:00:00 2001
From: daimond113 <72147841+daimond113@users.noreply.github.com>
Date: Mon, 8 Apr 2024 18:06:18 +0200
Subject: [PATCH] feat(website): add exports to sidebar
---
website/src/lib/Codeblock.svelte | 2 +-
website/src/routes/+layout.svelte | 2 +-
website/src/routes/docs/+page.svelte | 5 +-
.../[scope]/[name]/[version]/+page.svelte | 52 ++++++++++++-------
.../[scope]/[name]/[version]/+page.ts | 20 ++++++-
5 files changed, 55 insertions(+), 26 deletions(-)
diff --git a/website/src/lib/Codeblock.svelte b/website/src/lib/Codeblock.svelte
index ab19d56..d951714 100644
--- a/website/src/lib/Codeblock.svelte
+++ b/website/src/lib/Codeblock.svelte
@@ -8,7 +8,7 @@
{#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}
{@html highlightedCode}
{/await}
diff --git a/website/src/routes/+layout.svelte b/website/src/routes/+layout.svelte
index d58891a..f13117f 100644
--- a/website/src/routes/+layout.svelte
+++ b/website/src/routes/+layout.svelte
@@ -46,7 +46,7 @@
});
-
+
diff --git a/website/src/routes/docs/+page.svelte b/website/src/routes/docs/+page.svelte
index bfb1e00..7bab715 100644
--- a/website/src/routes/docs/+page.svelte
+++ b/website/src/routes/docs/+page.svelte
@@ -24,10 +24,7 @@
If you are using pesde with the `wally` feature enabled (true on releases from the GitHub
repository) then you can use 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
- as the default `https://github.com/daimond113/pesde-index`) yourself.
+ to pesde.yaml.
diff --git a/website/src/routes/packages/[scope]/[name]/[version]/+page.svelte b/website/src/routes/packages/[scope]/[name]/[version]/+page.svelte
index 4f2c893..8db296c 100644
--- a/website/src/routes/packages/[scope]/[name]/[version]/+page.svelte
+++ b/website/src/routes/packages/[scope]/[name]/[version]/+page.svelte
@@ -17,6 +17,8 @@
import ChevronDown from 'lucide-svelte/icons/chevron-down';
import Mail from 'lucide-svelte/icons/mail';
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;
@@ -38,20 +40,10 @@
]
});
- const parseAuthor = (author: string) => {
- const authorRegex =
- /^(?.+?)(?:\s*<(?.+?)>)?(?:\s*\((?.+?)\))?(?:\s*<(?.+?)>)?(?:\s*\((?.+?)\))?$/;
- const { groups } = author.match(authorRegex) ?? {};
- return {
- name: groups?.name ?? author,
- email: groups?.email ?? groups?.email2,
- url: groups?.url ?? groups?.url2
- };
- };
-
$: publishedAt = new Date(
(data.versions.find(([version]) => version === data.version)?.[1] ?? 0) * 1000
);
+
$: allDependencies = [
[data.dependencies, 'Dependencies'],
[data.peerDependencies, 'Peer Dependencies']
@@ -131,19 +123,18 @@
Authors
{#each data.authors as author}
- {@const parsedAuthor = parseAuthor(author)}
-
- {parsedAuthor.name}
+ {author.name}
- {#if parsedAuthor.email}
-
+ {#if author.email}
+
{/if}
- {#if parsedAuthor.url}
-
+ {#if author.url}
+
{/if}
@@ -160,7 +151,7 @@
{/if}
{#each allDependencies as [dependencies, title]}
- {#if dependencies}
+ {#if dependencies && dependencies.length > 0}
{/if}
{/each}
+
diff --git a/website/src/routes/packages/[scope]/[name]/[version]/+page.ts b/website/src/routes/packages/[scope]/[name]/[version]/+page.ts
index 8a17362..5693f19 100644
--- a/website/src/routes/packages/[scope]/[name]/[version]/+page.ts
+++ b/website/src/routes/packages/[scope]/[name]/[version]/+page.ts
@@ -8,6 +8,17 @@ export const ssr = false;
type Dependencies = ({ name: string; version: string } | { repo: string; rev: string })[];
+const parseAuthor = (author: string) => {
+ const authorRegex =
+ /^(?.+?)(?:\s*<(?.+?)>)?(?:\s*\((?.+?)\))?(?:\s*<(?.+?)>)?(?:\s*\((?.+?)\))?$/;
+ 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 }) => {
const res = await fetch(
`${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;
dependencies?: Dependencies;
peer_dependencies?: Dependencies;
+ exports?: { lib?: string; bin?: string };
};
if (params.version.toLowerCase() === 'latest') {
@@ -102,13 +114,17 @@ export const load: PageLoad = async ({ params, fetch }) => {
name: params.name,
version: parsed.version,
versions,
- authors: parsed.authors,
+ authors: parsed.authors?.map(parseAuthor),
description: parsed.description,
license: parsed.license,
readme,
repository: parsed.repository,
realm: parsed.realm,
dependencies: parsed.dependencies,
- peerDependencies: parsed.peer_dependencies
+ peerDependencies: parsed.peer_dependencies,
+ exports: {
+ lib: !!parsed.exports?.lib,
+ bin: !!parsed.exports?.bin
+ }
};
};