Add organizations, research groups and repo stats to projects
This commit is contained in:
1 parent
3fefc814e1
commit
c820672803
25 files changed
+573
-32
No files matched your search
@@ -1,16 +1,28 @@
|
||||
<script lang="ts">
|
||||
import Icon from '@iconify/svelte';
|
||||
import type { Project, ProjectCategory } from '#lib/content';
|
||||
import type { RepoStats } from '#lib/github/types';
|
||||
import LinkButton from '#lib/components/ui/LinkButton.svelte';
|
||||
import Tag from '#lib/components/ui/Tag.svelte';
|
||||
|
||||
let { project, category }: { project: Project; category: ProjectCategory } = $props();
|
||||
let {
|
||||
project,
|
||||
category,
|
||||
repoStats,
|
||||
downloads
|
||||
}: { project: Project; category: ProjectCategory; repoStats?: RepoStats; downloads?: number } = $props();
|
||||
|
||||
const downloadsLabel = $derived(
|
||||
downloads === undefined ? '' : new Intl.NumberFormat('en-US', { notation: 'compact' }).format(downloads)
|
||||
);
|
||||
|
||||
const linkButtons = $derived(
|
||||
[
|
||||
{ href: project.links.website, label: 'Website', icon: 'mdi:web' },
|
||||
{ href: project.links.demo, label: 'View Demo', icon: 'mdi:open-in-new' },
|
||||
{ href: project.links.package, label: 'View Package', icon: 'mdi:package-variant' },
|
||||
{ href: project.links.code, label: 'View Code', icon: 'mdi:github' },
|
||||
{ href: project.links.docs, label: 'Docs', icon: 'mdi:book-open-page-variant-outline' },
|
||||
{ href: project.links.devpost, label: 'Devpost', icon: 'simple-icons:devpost' },
|
||||
{ href: project.links.article, label: 'Article', icon: 'mdi:newspaper-variant-outline' }
|
||||
].filter((button) => button.href)
|
||||
@@ -33,6 +45,28 @@
|
||||
{#if project.version}
|
||||
<span class="badge version">v{project.version}</span>
|
||||
{/if}
|
||||
{#if repoStats && project.links.code}
|
||||
<a class="repo-stat stars" href="{project.links.code}/stargazers" target="_blank" rel="noopener noreferrer" title="GitHub stars">
|
||||
<Icon icon="mdi:star-outline" width="15" />
|
||||
{repoStats.stars}
|
||||
</a>
|
||||
<a class="repo-stat forks" href="{project.links.code}/forks" target="_blank" rel="noopener noreferrer" title="GitHub forks">
|
||||
<Icon icon="mdi:source-fork" width="15" />
|
||||
{repoStats.forks}
|
||||
</a>
|
||||
{/if}
|
||||
{#if downloads !== undefined && project.links.package}
|
||||
<a
|
||||
class="repo-stat downloads"
|
||||
href={project.links.package}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title="{downloads.toLocaleString('en-US')} npm downloads"
|
||||
>
|
||||
<Icon icon="mdi:download" width="15" />
|
||||
{downloadsLabel}
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if project.event}
|
||||
@@ -78,10 +112,82 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if project.gallery?.length}
|
||||
<div class="gallery" data-image-group>
|
||||
{#each project.gallery as photo, index (photo)}
|
||||
<a class="gallery-item" href={photo} target="_blank" rel="noopener noreferrer">
|
||||
<img src={photo} alt="{project.name} photo {index + 1}" loading="lazy" />
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if project.socials?.length}
|
||||
<div class="socials">
|
||||
{#each project.socials as social (social.url)}
|
||||
<a class="social" href={social.url} target="_blank" rel="noopener noreferrer" title={social.name}>
|
||||
<Icon icon={social.icon} width="16" />
|
||||
<span>{social.name}</span>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<style>
|
||||
.gallery {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
gap: 0.5rem;
|
||||
max-width: 640px;
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
|
||||
.gallery-item {
|
||||
display: block;
|
||||
aspect-ratio: 4 / 3;
|
||||
overflow: hidden;
|
||||
border: 1px solid color-mix(in srgb, var(--foreground) 20%, transparent);
|
||||
transition: border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.gallery-item:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.gallery-item img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.gallery-item:hover img {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.socials {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 0.9rem;
|
||||
margin-top: 0.2rem;
|
||||
}
|
||||
|
||||
.social {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
color: var(--muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.social:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.project-entry {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
@@ -153,6 +259,31 @@
|
||||
background: var(--blue);
|
||||
}
|
||||
|
||||
.repo-stat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding: 0 0.45rem;
|
||||
border: 1px solid color-mix(in srgb, var(--foreground) 25%, transparent);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.repo-stat.stars {
|
||||
color: var(--yellow);
|
||||
}
|
||||
|
||||
.repo-stat.forks {
|
||||
color: var(--cyan);
|
||||
}
|
||||
|
||||
.repo-stat.downloads {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.repo-stat:hover {
|
||||
border-color: currentColor;
|
||||
}
|
||||
|
||||
.event {
|
||||
color: var(--blue);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user