mirror of
https://github.com/LukeHagar/sveltesociety.dev.git
synced 2025-12-07 20:57:45 +00:00
feat: Add script to get npm package data (#499)
* Add zod schemas for CI validation * Require npm field for components.json * Remove svelte-layout-resizable * Stricter Zod validation * Stricter repository field validation * Implement requested changes * Add back accidentally removed field * Move SvelteStore to templates.json * Update category and tags * Add script to get npm data * Re-run updateNpm.js * Implement initial feedback * Update npm.js * Switch async/await to then/catch Co-authored-by: MacFJA <MacFJA@users.noreply.github.com> * Fix prettier * Run script * Re-run updateNpm * Also read tools.json * Add @types/node * Restructure npm.json output * Display last update on components page * Add to weekly workflow * Clarify updating npm data * Update src/lib/utils/injectNpmData.ts Co-authored-by: MacFJA <MacFJA@users.noreply.github.com> * Smaller date font, add version * Improve error text * Fix property title --------- Co-authored-by: MacFJA <MacFJA@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import Tag from '../Tag.svelte';
|
||||
import { copyToClipboard } from '$lib/utils/clipboard';
|
||||
import { packageManager as manager } from '$stores/packageManager';
|
||||
import { relativeDate } from '$utils/relativeDate';
|
||||
|
||||
export let active = false;
|
||||
export let title = '';
|
||||
@@ -11,6 +12,8 @@
|
||||
export let url = '';
|
||||
export let npm = '';
|
||||
export let repository = undefined;
|
||||
export let date = undefined;
|
||||
export let version = undefined;
|
||||
|
||||
let clipboardCopy = false;
|
||||
|
||||
@@ -33,15 +36,35 @@
|
||||
</script>
|
||||
|
||||
<div class="card" class:active id="component-{title}">
|
||||
<h3>
|
||||
<a href="#component-{title}">#</a>
|
||||
{#if url || repository}<a href={url || repository}>{title}</a>{:else}<span>{title}</span>{/if}
|
||||
{#if npm}<Tag
|
||||
click={() => copy()}
|
||||
variant="copy"
|
||||
title={clipboardCopy ? 'copied!' : `${packageManagers[$manager]} ${cleanupNpm(npm)}`}
|
||||
/>{/if}
|
||||
</h3>
|
||||
<div class="card__top">
|
||||
<div>
|
||||
<h3>
|
||||
<a href="#component-{title}">#</a>
|
||||
{#if url || repository}<a href={url || repository}>{title}</a>{:else}<span>{title}</span
|
||||
>{/if}
|
||||
</h3>
|
||||
</div>
|
||||
<div>
|
||||
{#if (repository || url || '').includes('github')}
|
||||
<a class="repo" title="Go to the source code" href={repository || url}
|
||||
><img style="display:inline" src="/images/github_logo.svg" alt="github logo" /></a
|
||||
>
|
||||
{:else if (repository || url || '').includes('gitlab')}
|
||||
<a class="repo" title="Go to the source code" href={repository || url}
|
||||
><img style="display:inline" src="/images/gitlab_logo.svg" alt="gitlab logo" /></a
|
||||
>
|
||||
<!-- {:else} -->
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if npm}
|
||||
<Tag
|
||||
click={() => copy()}
|
||||
variant="copy"
|
||||
title={clipboardCopy ? 'copied!' : `${packageManagers[$manager]} ${cleanupNpm(npm)}`}
|
||||
/>
|
||||
{/if}
|
||||
<p class="flex-grow">{description}</p>
|
||||
{#if tags}
|
||||
<div class="card__tags">
|
||||
@@ -51,26 +74,13 @@
|
||||
</div>
|
||||
{/if}
|
||||
<div class="card__bottom">
|
||||
<div>
|
||||
{#if (repository || url || '').includes('github')}
|
||||
<a title="Go to the source code" href={repository || url}
|
||||
><img style="display:inline" src="/images/github_logo.svg" alt="github logo" /></a
|
||||
>
|
||||
{:else if (repository || url || '').includes('gitlab')}
|
||||
<a title="Go to the source code" href={repository || url}
|
||||
><img style="display:inline" src="/images/gitlab_logo.svg" alt="gitlab logo" /></a
|
||||
>
|
||||
<!-- {:else} -->
|
||||
{/if}
|
||||
</div>
|
||||
<div>
|
||||
{#if typeof stars !== 'undefined'}
|
||||
★
|
||||
<code>{stars}</code>
|
||||
{/if}
|
||||
</div>
|
||||
<!-- commenting out dates just cause it is not very updated yet - all the cards show same date. put back in when we have better scraping -->
|
||||
<!-- <datetime value={addedOn}>{new Intl.DateTimeFormat('en-Us').format(Date.parse(addedOn))}</datetime> -->
|
||||
{#if date && version}<span class="date">Updated {relativeDate(date)} ({version})</span>{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,6 +107,11 @@
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.card__top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: top;
|
||||
}
|
||||
.card__bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -105,7 +120,7 @@
|
||||
.card__bottom > * {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.card__bottom a {
|
||||
.repo {
|
||||
border-bottom: none;
|
||||
aspect-ratio: 1/1;
|
||||
display: flex;
|
||||
@@ -117,10 +132,12 @@
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
transition: background-color 200ms ease-out;
|
||||
}
|
||||
.card__bottom a:hover {
|
||||
.repo:hover {
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 14px;
|
||||
}
|
||||
.flex-grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user