Skip to content

Commit 70e6c6a

Browse files
authored
feat: contributors section (#66)
1 parent fc47021 commit 70e6c6a

File tree

6 files changed

+68
-4
lines changed

6 files changed

+68
-4
lines changed

.changeset/solid-groups-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@svecodocs/kit": minor
3+
---
4+
5+
feat: Contributors section

.changeset/tricky-moles-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@svecodocs/kit": patch
3+
---
4+
5+
feat: forward component props to docpage component
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script lang="ts">
2+
import type { Contributor } from "$lib/types.js";
3+
import { Avatar } from "bits-ui";
4+
import H2 from "./markdown/h2.svelte";
5+
6+
let { contributors }: { contributors: Contributor[] } = $props();
7+
</script>
8+
9+
{#if contributors.length > 0}
10+
<H2 id="contributors">Contributors</H2>
11+
<p></p>
12+
<div class="mt-6 flex select-none flex-wrap gap-1.5">
13+
{#each contributors as contributor (contributor.login)}
14+
<a
15+
href="https://github.com/{contributor.login}"
16+
target="_blank"
17+
class="group flex items-center gap-2 rounded-lg px-2 py-1.5"
18+
>
19+
<Avatar.Root
20+
class="border-foreground/50 group-hover:border-foreground size-8 rounded-full border"
21+
>
22+
<Avatar.Image
23+
class="rounded-full"
24+
src={contributor.avatar_url}
25+
alt={contributor.name}
26+
/>
27+
<Avatar.Fallback>
28+
{contributor.name?.charAt(0)}
29+
</Avatar.Fallback>
30+
</Avatar.Root>
31+
<span class="underline-offset-2 group-hover:underline"
32+
>{contributor.name ?? contributor.login}</span
33+
>
34+
</a>
35+
{/each}
36+
</div>
37+
{/if}

packages/kit/src/lib/components/layout/doc-page.svelte

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,47 @@
22
import PageHeader from "$lib/components/layout/page-header/page-header.svelte";
33
import Toc from "$lib/components/toc/toc.svelte";
44
import type { Component, ComponentProps } from "svelte";
5-
import type { TOCEntry } from "$lib/types.js";
5+
import type { Contributor, TOCEntry } from "$lib/types.js";
66
import Metadata from "../metadata.svelte";
7+
import ContributorSection from "../contributors-section.svelte";
78
89
let {
910
component,
11+
componentProps = {},
1012
title,
1113
description,
1214
toc,
1315
metadata = {},
16+
contributors = [],
1417
}: {
1518
component: Component;
19+
componentProps?: Record<string, unknown>;
1620
title: string;
1721
description?: string;
1822
toc: TOCEntry[];
1923
metadata?: ComponentProps<typeof Metadata>;
24+
contributors?: Contributor[];
2025
} = $props();
2126
2227
const PageComponent = $derived(component);
28+
const tocItems = $derived(
29+
contributors.length ? [...toc, { title: "Contributors", url: "#contributors" }] : toc
30+
);
2331
</script>
2432

2533
<Metadata {...metadata} {title} {description} />
2634
<aside class="sticky">
2735
<div class="sticky top-24 hidden pl-16 xl:block">
28-
<Toc toc={{ items: toc }} />
36+
<Toc toc={{ items: tocItems }} />
2937
</div>
3038
</aside>
3139
<div class="mx-auto">
3240
<aside>
33-
<Toc toc={{ items: toc }} type="mobile" />
41+
<Toc toc={{ items: tocItems }} type="mobile" />
3442
</aside>
3543
<main class="mx-auto w-full min-w-0 max-w-[640px] pb-12 2xl:max-w-[760px]" id="main-content">
3644
<PageHeader {title} {description} />
37-
<PageComponent />
45+
<PageComponent {...componentProps} />
46+
<ContributorSection {contributors} />
3847
</main>
3948
</div>

packages/kit/src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export { default as DemoContainer } from "./components/demo-container.svelte";
55
export { default as ScrollArea } from "./components/ui/scroll-area/scroll-area.svelte";
66
export { default as Card } from "./components/card.svelte";
77
export { default as CardGrid } from "./components/card-grid.svelte";
8+
export { default as ContributorsSection } from "./components/contributors-section.svelte";
89
export { default as Button } from "./components/ui/button/button.svelte";
910
export { default as Tabs } from "./components/tabs/tabs.svelte";
1011
export { default as TabItem } from "./components/tabs/tab-item.svelte";

packages/kit/src/lib/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,10 @@ export type TOCEntry = {
5454
url: string;
5555
items?: TOCEntry[];
5656
};
57+
58+
export type Contributor = {
59+
login: string;
60+
name?: string;
61+
avatar_url: string;
62+
contributions: number;
63+
};

0 commit comments

Comments
 (0)