@grove-dev/cli 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/health-cli.d.ts +3 -0
- package/dist/health-cli.d.ts.map +1 -0
- package/dist/health-cli.js +15 -0
- package/dist/health-cli.js.map +1 -0
- package/dist/health.d.ts +7 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +68 -0
- package/dist/health.js.map +1 -0
- package/dist/icons-cli.d.ts.map +1 -1
- package/dist/icons-cli.js +2 -1
- package/dist/icons-cli.js.map +1 -1
- package/dist/index.js +38 -18
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +27 -12
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +180 -53
- package/dist/init.js.map +1 -1
- package/dist/package-manager.d.ts +57 -0
- package/dist/package-manager.d.ts.map +1 -0
- package/dist/package-manager.js +157 -0
- package/dist/package-manager.js.map +1 -0
- package/dist/package.json +3 -2
- package/dist/r/about.json +2 -1
- package/dist/r/browse.json +2 -1
- package/dist/r/collections.json +2 -1
- package/dist/r/contributors.json +2 -1
- package/dist/r/default.json +7 -6
- package/dist/r/home.json +2 -1
- package/dist/r/not-found.json +2 -1
- package/dist/r/project-card.json +2 -1
- package/dist/r/record.json +3 -2
- package/dist/r/registry.json +26 -13
- package/dist/r/shell.json +2 -1
- package/dist/r/submit.json +3 -2
- package/dist/r/taxonomy.json +5 -4
- package/dist/r/ui.json +2 -1
- package/dist/registry.d.ts +6 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js.map +1 -1
- package/dist/update.d.ts +24 -5
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +83 -3
- package/dist/update.js.map +1 -1
- package/package.json +5 -4
package/dist/r/default.json
CHANGED
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"path": "default/pages/categories/[name].astro",
|
|
153
|
-
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const categories = siteConfig.taxonomy?.categories ?? [];\n return categories.map(({ id, name }) => ({\n
|
|
153
|
+
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const categories = siteConfig.taxonomy?.categories ?? [];\n // A category no record currently uses gets no page at all — the\n // static host 404s the request instead of publishing a thin,\n // indexable \"0 apps\" page for it.\n return categories\n .filter(({ count }) => (count ?? 0) > 0)\n .map(({ id, name }) => ({\n params: { name: id },\n props: { displayName: name },\n }));\n}\n\nconst { displayName } = Astro.props;\nconst name = Astro.params.name;\nconst model = getTaxonomyPageModel('categories', name, displayName, siteConfig);\n---\n\n<BaseLayout\n title={model.seo.title}\n description={model.seo.description}\n image={model.seo.image}\n imageAlt={model.seo.imageAlt}\n jsonLd={model.seo.jsonLd}\n site={siteConfig}\n>\n <TaxonomyList\n eyebrow=\"Category\"\n displayName={displayName}\n lede={`Browse ${itemLabelPlural()} in this directory in the ${displayName} category.`}\n records={model.records}\n />\n</BaseLayout>\n",
|
|
154
154
|
"type": "registry:page",
|
|
155
155
|
"target": "~/src/pages/categories/[name].astro"
|
|
156
156
|
},
|
|
@@ -162,13 +162,13 @@
|
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
"path": "default/pages/stacks/[name].astro",
|
|
165
|
-
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const stacks = siteConfig.taxonomy?.stacks ?? [];\n return stacks.map(({ id, name }) => ({\n
|
|
165
|
+
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const stacks = siteConfig.taxonomy?.stacks ?? [];\n // A stack no record currently uses gets no page at all — the\n // static host 404s the request instead of publishing a thin,\n // indexable \"0 apps\" page for it.\n return stacks\n .filter(({ count }) => (count ?? 0) > 0)\n .map(({ id, name }) => ({\n params: { name: id },\n props: { displayName: name },\n }));\n}\n\nconst { displayName } = Astro.props;\nconst name = Astro.params.name;\nconst model = getTaxonomyPageModel('stacks', name, displayName, siteConfig);\n---\n\n<BaseLayout\n title={model.seo.title}\n description={model.seo.description}\n image={model.seo.image}\n imageAlt={model.seo.imageAlt}\n jsonLd={model.seo.jsonLd}\n site={siteConfig}\n>\n <TaxonomyList\n eyebrow=\"Stack\"\n displayName={displayName}\n lede={`Browse ${itemLabelPlural()} in this directory built with ${displayName}.`}\n records={model.records}\n />\n</BaseLayout>\n",
|
|
166
166
|
"type": "registry:page",
|
|
167
167
|
"target": "~/src/pages/stacks/[name].astro"
|
|
168
168
|
},
|
|
169
169
|
{
|
|
170
170
|
"path": "default/pages/licenses/[name].astro",
|
|
171
|
-
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const licenses = siteConfig.taxonomy?.licenses ?? [];\n return licenses.map(({ id, name }) => ({\n
|
|
171
|
+
"content": "---\nimport siteConfig from '@grove/generated/site-config.json';\nimport { getTaxonomyPageModel, itemLabelPlural } from '@grove-dev/astro/server';\nimport TaxonomyList from '../../components/grove/taxonomy-list.astro';\nimport BaseLayout from '../../layouts/base-layout.astro';\n\nexport function getStaticPaths() {\n const licenses = siteConfig.taxonomy?.licenses ?? [];\n // A license no record currently uses gets no page at all — the\n // static host 404s the request instead of publishing a thin,\n // indexable \"0 apps\" page for it.\n return licenses\n .filter(({ count }) => (count ?? 0) > 0)\n .map(({ id, name }) => ({\n params: { name: id },\n props: { displayName: name },\n }));\n}\n\nconst { displayName } = Astro.props;\nconst name = Astro.params.name;\nconst model = getTaxonomyPageModel('licenses', name, displayName, siteConfig);\n---\n\n<BaseLayout\n title={model.seo.title}\n description={model.seo.description}\n image={model.seo.image}\n imageAlt={model.seo.imageAlt}\n jsonLd={model.seo.jsonLd}\n site={siteConfig}\n>\n <TaxonomyList\n eyebrow=\"License\"\n displayName={displayName}\n lede={`Browse ${itemLabelPlural()} in this directory licensed under ${displayName}.`}\n records={model.records}\n />\n</BaseLayout>\n",
|
|
172
172
|
"type": "registry:page",
|
|
173
173
|
"target": "~/src/pages/licenses/[name].astro"
|
|
174
174
|
},
|
|
@@ -366,7 +366,7 @@
|
|
|
366
366
|
},
|
|
367
367
|
{
|
|
368
368
|
"path": "default/components/grove/record-sidebar.astro",
|
|
369
|
-
"content": "---\nimport type { RecordDetailModel } from '@grove-dev/astro/server';\nimport { taxonomyLabel } from '@grove-dev/astro/server';\n/**\n * RecordSidebar.astro\n *\n * Sticky right-hand column on the record detail page. Renders\n * up to four cards, each conditional on the model's `sidebar`\n * visibility flags:\n *\n * - Activity — repo facts (stars, forks, language, license, …)\n * - Freshness — last commit / last fetch / maintenance status\n * - Ecosystem — stack, platforms, category, tags, hygiene files\n * - Source — curation metadata + reading-time summary\n *\n * Empty rows are suppressed entirely — the sidebar never shows \"—\"\n * or \"0\" placeholders that confuse \"no data\" with \"zero\".\n *\n * Sticky on lg+ (`lg:sticky lg:top-20 lg:max-h-calc(100vh-5rem)\n * lg:overflow-y-auto`) so the cards stay in view while the user\n * scrolls the body. Cards are individually rendered so the\n * sticky container's height is bounded by the actual content.\n */\nimport { licenseDisplay } from '@grove-dev/core';\nimport Badge from '../ui/badge.astro';\nimport Icon from './icon.astro';\nimport LanguageBreakdown from './language-breakdown.astro';\n\ninterface Props {\n detail: RecordDetailModel;\n /**\n * Pass false when a parent wrapper owns the sticky behavior (e.g.\n * the detail page stacks the TOC above this sidebar inside one\n * sticky column).\n */\n sticky?: boolean;\n /**\n * \"column\" (default) stacks the cards vertically for a rail;\n * \"grid\" lays them out in responsive columns for full-width\n * placement below the article.\n */\n layout?: 'column' | 'grid';\n}\n\nconst { detail, sticky = true, layout = 'column' } = Astro.props;\nconst {\n sidebar,\n github,\n stars,\n forks,\n language,\n licenseSpdx,\n pushedLabel,\n repoUrl,\n ownerRepo,\n healthLabel,\n activityBadge,\n stacks,\n platforms,\n tags,\n category,\n contributionSignals,\n languages,\n totalLanguageBytes,\n readingMetrics,\n record,\n firstCommitYear,\n lastFetchedLabel,\n reviewedAtLabel,\n} = detail;\nconst alsoIn: Array<{ url: string; title: string }> = detail.collectionMembership ?? [];\n\n// Visibility helpers for individual rows inside the Activity card.\n// `hasRepo` is the discriminator between \"GitHub data synced\" and\n// \"no data fetched yet\" — without it the card would show \"Stars 0\"\n// even when the field was never populated.\nconst repo = github;\nconst hasRepo = !!repo;\nconst starsNumber = typeof stars === 'number' && stars > 0 ? stars : null;\nconst forksNumber = typeof forks === 'number' && forks > 0 ? forks : null;\n// `repo` is a loosely-typed passthrough of the raw GitHub API response\n// (see `@grove-dev/astro/server`'s `getRecordDetailModel`) — `releases`\n// isn't in the normalized `githubMetadataSchema`, so it arrives as\n// `unknown` and needs a local shape for the three fields read below.\nconst recentReleases = (\n (repo?.releases as Array<{ html_url?: string; tag_name?: string; name?: string }> | undefined) ??\n []\n).slice(0, 1);\nconst isArchived = !!repo?.archived;\n\n// Render a kv row only when both the label and value have content.\nfunction row(label: string, value: unknown) {\n if (value === null || value === undefined || value === '') return null;\n return { label, value };\n}\n---\n\n<aside\n class:list={[\n layout === \"grid\"\n ? \"grove-sidebar grid grid-cols-1 items-start gap-4 sm:grid-cols-2 xl:grid-cols-4\"\n : \"grove-sidebar flex flex-col gap-4\",\n layout === \"column\" &&\n sticky &&\n \"lg:sticky lg:top-20 lg:max-h-[calc(100vh-5rem)] lg:self-start lg:overflow-y-auto\",\n ]}\n aria-label=\"Record metadata\"\n>\n\n {/* ── Activity card ──────────────────────────────────────── */}\n {sidebar.showActivity && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-activity-title\"\n >\n <h2\n id=\"sidebar-activity-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Activity\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {row(\"Stars\", starsNumber !== null ? starsNumber : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Stars</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{starsNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Forks\", forksNumber !== null ? forksNumber.toLocaleString() : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Forks</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{forksNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Contributors\", repo?.contributors_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Contributors</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.contributors_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Open issues\", repo?.open_issues_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Open issues</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.open_issues_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Watchers\", repo?.subscribers_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Watchers</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.subscribers_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Language\", language) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Language</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{language}</dd>\n </div>\n )}\n {row(\"License\", licenseSpdx) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">License</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{licenseDisplay(licenseSpdx)}</dd>\n </div>\n )}\n {row(\"Default branch\", repo?.default_branch) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Default branch</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{repo!.default_branch}</dd>\n </div>\n )}\n {row(\"First commit\", firstCommitYear) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">First commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo!.created_at)}>{firstCommitYear}</time>\n </dd>\n </div>\n )}\n {recentReleases[0] && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Latest release</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a\n href={recentReleases[0].html_url ?? repoUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"no-underline hover:underline\"\n >\n {recentReleases[0].tag_name ?? recentReleases[0].name ?? \"—\"}\n </a>\n </dd>\n </div>\n )}\n </dl>\n\n <LanguageBreakdown languages={languages} totalBytes={totalLanguageBytes} />\n </section>\n )}\n\n {/* ── Freshness card ─────────────────────────────────────── */}\n {sidebar.showFreshness && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-freshness-title\"\n >\n <h2\n id=\"sidebar-freshness-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Freshness\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {pushedLabel && pushedLabel !== \"—\" && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{pushedLabel}</dd>\n </div>\n )}\n {repo?.updated_at && lastFetchedLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last fetched</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo.updated_at)}>{lastFetchedLabel}</time>\n </dd>\n </div>\n )}\n {activityBadge && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Maintenance</dt>\n <dd>\n <span data-activity-tone={activityBadge.tone} class=\"grove-pill grove-pill--activity inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium\">\n {activityBadge.label}\n </span>\n </dd>\n </div>\n )}\n {healthLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Health</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{healthLabel}</dd>\n </div>\n )}\n {isArchived && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Status</dt>\n <dd><Badge variant=\"warning\">Archived</Badge></dd>\n </div>\n )}\n {repo?.homepage && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Docs</dt>\n <dd class=\"truncate text-ink-900 dark:text-ink-100\">\n <a href={String(repo.homepage)} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {new URL(String(repo.homepage)).hostname}\n </a>\n </dd>\n </div>\n )}\n {repoUrl && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Source</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a href={repoUrl} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {ownerRepo ? `${ownerRepo.owner}/${ownerRepo.repo}` : repoUrl}\n </a>\n </dd>\n </div>\n )}\n </dl>\n </section>\n )}\n\n {/* ── Ecosystem card ─────────────────────────────────────── */}\n {sidebar.showEcosystem && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-ecosystem-title\"\n >\n <h2\n id=\"sidebar-ecosystem-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Ecosystem\n </h2>\n\n {stacks.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Stack</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {stacks.map((s) => (\n <li>\n <a href={`/${detail.slug}?stack=${encodeURIComponent(s)}`} class=\"inline-flex items-center gap-1.5 rounded-full bg-secondary py-0.5 pl-1.5 pr-2 text-2xs font-medium text-secondary-foreground no-underline\">\n <Icon name={s} category=\"stack\" size={12} />\n {taxonomyLabel(\"stacks\", s)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {platforms.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Platforms</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {platforms.map((p) => (\n <li class=\"inline-flex items-center gap-1.5 rounded-full border border-ink-200 py-0.5 pl-1.5 pr-2 text-2xs font-medium text-ink-700 dark:border-ink-800 dark:text-ink-300\">\n <Icon name={p} category=\"platform\" size={12} />\n {taxonomyLabel(\"platforms\", p)}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {category && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Category</h3>\n <a href={`/${detail.slug}?category=${encodeURIComponent(category)}`} class=\"rounded-full bg-secondary px-2 py-0.5 text-2xs font-medium text-secondary-foreground no-underline\">\n {taxonomyLabel(\"categories\", category)}\n </a>\n </div>\n )}\n\n {tags.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Tags</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {tags.map((t) => (\n <li>\n <a href={`/${detail.slug}?tag=${encodeURIComponent(t)}`} class=\"rounded-full border border-ink-200 px-2 py-0.5 text-2xs font-medium text-ink-700 no-underline dark:border-ink-800 dark:text-ink-300\">\n {taxonomyLabel(\"topics\", t)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {contributionSignals.length > 0 && (\n <div>\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Repository hygiene</h3>\n <ul class=\"m-0 flex list-none flex-col gap-1 p-0 text-sm\">\n {contributionSignals.map((s) => (\n <li class=\"inline-flex items-center gap-1.5 text-ink-700 dark:text-ink-200\">\n {s.ok ? (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-emerald-600 dark:text-emerald-400\">\n <path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" />\n </svg>\n ) : (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-ink-400\">\n <path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\" />\n </svg>\n )}\n {s.label}\n </li>\n ))}\n </ul>\n </div>\n )}\n </section>\n )}\n\n {/* ── Source card (small) ────────────────────────────────── */}\n {sidebar.showSource && (\n <section\n class=\"grove-card grove-card--muted rounded-[var(--radius-lg)] border border-dashed border-ink-200 bg-card/50 p-4 text-2xs text-ink-500 dark:border-ink-800 dark:text-ink-400\"\n aria-labelledby=\"sidebar-source-title\"\n >\n <h2\n id=\"sidebar-source-title\"\n class=\"grove-card-title m-0 mb-1.5 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Source\n </h2>\n <p class=\"m-0 leading-relaxed\">\n Reviewed by {record.curation?.reviewedBy ?? \"grove\"}\n on <time datetime={String(record.curation?.reviewedAt)}>\n {reviewedAtLabel ?? \"—\"}\n </time>.\n </p>\n {alsoIn.length > 0 && (\n <p class=\"m-0 mt-1.5 leading-relaxed\">\n <span class=\"font-semibold\">Also in: </span>\n {alsoIn.map((c, i) => (\n <>\n <a href={c.url} class=\"text-inherit no-underline hover:underline\">{c.title}</a>{i < alsoIn.length - 1 ? \", \" : \"\"}\n </>\n ))}\n </p>\n )}\n {readingMetrics.wordCount > 0 && (\n <p class=\"m-0 mt-1 leading-relaxed\">\n Notes: {readingMetrics.wordCount.toLocaleString()} words · {readingMetrics.minutes} min read.\n </p>\n )}\n </section>\n )}\n</aside>",
|
|
369
|
+
"content": "---\nimport type { RecordDetailModel } from '@grove-dev/astro/server';\nimport { taxonomyLabel } from '@grove-dev/astro/server';\n/**\n * RecordSidebar.astro\n *\n * Sticky right-hand column on the record detail page. Renders\n * up to four cards, each conditional on the model's `sidebar`\n * visibility flags:\n *\n * - Activity — repo facts (stars, forks, language, license, …)\n * - Freshness — last commit / last fetch / maintenance status\n * - Ecosystem — stack, platforms, category, tags, hygiene files\n * - Source — curation metadata + reading-time summary\n *\n * Empty rows are suppressed entirely — the sidebar never shows \"—\"\n * or \"0\" placeholders that confuse \"no data\" with \"zero\".\n *\n * Sticky on lg+ (`lg:sticky lg:top-20 lg:max-h-calc(100vh-5rem)\n * lg:overflow-y-auto`) so the cards stay in view while the user\n * scrolls the body. Cards are individually rendered so the\n * sticky container's height is bounded by the actual content.\n */\nimport { licenseDisplay } from '@grove-dev/core';\nimport Badge from '../ui/badge.astro';\nimport Icon from './icon.astro';\nimport LanguageBreakdown from './language-breakdown.astro';\n\ninterface Props {\n detail: RecordDetailModel;\n /**\n * Pass false when a parent wrapper owns the sticky behavior (e.g.\n * the detail page stacks the TOC above this sidebar inside one\n * sticky column).\n */\n sticky?: boolean;\n /**\n * \"column\" (default) stacks the cards vertically for a rail;\n * \"grid\" lays them out in responsive columns for full-width\n * placement below the article.\n */\n layout?: 'column' | 'grid';\n}\n\nconst { detail, sticky = true, layout = 'column' } = Astro.props;\nconst {\n sidebar,\n github,\n stars,\n forks,\n language,\n licenseSpdx,\n pushedLabel,\n repoUrl,\n ownerRepo,\n healthLabel,\n activityBadge,\n stacks,\n platforms,\n tags,\n category,\n contributionSignals,\n languages,\n totalLanguageBytes,\n readingMetrics,\n record,\n firstCommitYear,\n lastFetchedLabel,\n reviewedAtLabel,\n addedAtLabel,\n} = detail;\nconst alsoIn: Array<{ url: string; title: string }> = detail.collectionMembership ?? [];\n\n// Visibility helpers for individual rows inside the Activity card.\n// `hasRepo` is the discriminator between \"GitHub data synced\" and\n// \"no data fetched yet\" — without it the card would show \"Stars 0\"\n// even when the field was never populated.\nconst repo = github;\nconst hasRepo = !!repo;\nconst starsNumber = typeof stars === 'number' && stars > 0 ? stars : null;\nconst forksNumber = typeof forks === 'number' && forks > 0 ? forks : null;\n// `repo` is a loosely-typed passthrough of the raw GitHub API response\n// (see `@grove-dev/astro/server`'s `getRecordDetailModel`) — `releases`\n// isn't in the normalized `githubMetadataSchema`, so it arrives as\n// `unknown` and needs a local shape for the three fields read below.\nconst recentReleases = (\n (repo?.releases as Array<{ html_url?: string; tag_name?: string; name?: string }> | undefined) ??\n []\n).slice(0, 1);\nconst isArchived = !!repo?.archived;\n\n// Render a kv row only when both the label and value have content.\nfunction row(label: string, value: unknown) {\n if (value === null || value === undefined || value === '') return null;\n return { label, value };\n}\n---\n\n<aside\n class:list={[\n layout === \"grid\"\n ? \"grove-sidebar grid grid-cols-1 items-start gap-4 sm:grid-cols-2 xl:grid-cols-4\"\n : \"grove-sidebar flex flex-col gap-4\",\n layout === \"column\" &&\n sticky &&\n \"lg:sticky lg:top-20 lg:max-h-[calc(100vh-5rem)] lg:self-start lg:overflow-y-auto\",\n ]}\n aria-label=\"Record metadata\"\n>\n\n {/* ── Activity card ──────────────────────────────────────── */}\n {sidebar.showActivity && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-activity-title\"\n >\n <h2\n id=\"sidebar-activity-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Activity\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {row(\"Stars\", starsNumber !== null ? starsNumber : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Stars</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{starsNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Forks\", forksNumber !== null ? forksNumber.toLocaleString() : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Forks</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{forksNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Contributors\", repo?.contributors_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Contributors</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.contributors_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Open issues\", repo?.open_issues_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Open issues</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.open_issues_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Watchers\", repo?.subscribers_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Watchers</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.subscribers_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Language\", language) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Language</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{language}</dd>\n </div>\n )}\n {row(\"License\", licenseSpdx) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">License</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{licenseDisplay(licenseSpdx)}</dd>\n </div>\n )}\n {row(\"Default branch\", repo?.default_branch) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Default branch</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{repo!.default_branch}</dd>\n </div>\n )}\n {row(\"First commit\", firstCommitYear) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">First commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo!.created_at)}>{firstCommitYear}</time>\n </dd>\n </div>\n )}\n {recentReleases[0] && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Latest release</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a\n href={recentReleases[0].html_url ?? repoUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"no-underline hover:underline\"\n >\n {recentReleases[0].tag_name ?? recentReleases[0].name ?? \"—\"}\n </a>\n </dd>\n </div>\n )}\n </dl>\n\n <LanguageBreakdown languages={languages} totalBytes={totalLanguageBytes} />\n </section>\n )}\n\n {/* ── Freshness card ─────────────────────────────────────── */}\n {sidebar.showFreshness && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-freshness-title\"\n >\n <h2\n id=\"sidebar-freshness-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Freshness\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {pushedLabel && pushedLabel !== \"—\" && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{pushedLabel}</dd>\n </div>\n )}\n {repo?.updated_at && lastFetchedLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last fetched</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo.updated_at)}>{lastFetchedLabel}</time>\n </dd>\n </div>\n )}\n {activityBadge && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Maintenance</dt>\n <dd>\n <span data-activity-tone={activityBadge.tone} class=\"grove-pill grove-pill--activity inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium\">\n {activityBadge.label}\n </span>\n </dd>\n </div>\n )}\n {healthLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Health</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{healthLabel}</dd>\n </div>\n )}\n {isArchived && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Status</dt>\n <dd><Badge variant=\"warning\">Archived</Badge></dd>\n </div>\n )}\n {repo?.homepage && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Docs</dt>\n <dd class=\"truncate text-ink-900 dark:text-ink-100\">\n <a href={String(repo.homepage)} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {new URL(String(repo.homepage)).hostname}\n </a>\n </dd>\n </div>\n )}\n {repoUrl && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Source</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a href={repoUrl} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {ownerRepo ? `${ownerRepo.owner}/${ownerRepo.repo}` : repoUrl}\n </a>\n </dd>\n </div>\n )}\n </dl>\n </section>\n )}\n\n {/* ── Ecosystem card ─────────────────────────────────────── */}\n {sidebar.showEcosystem && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-ecosystem-title\"\n >\n <h2\n id=\"sidebar-ecosystem-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Ecosystem\n </h2>\n\n {stacks.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Stack</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {stacks.map((s) => (\n <li>\n <a href={`/stacks/${s}`} class=\"inline-flex items-center gap-1.5 rounded-full bg-secondary py-0.5 pl-1.5 pr-2 text-2xs font-medium text-secondary-foreground no-underline\">\n <Icon name={s} category=\"stack\" size={12} />\n {taxonomyLabel(\"stacks\", s)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {platforms.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Platforms</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {platforms.map((p) => (\n <li class=\"inline-flex items-center gap-1.5 rounded-full border border-ink-200 py-0.5 pl-1.5 pr-2 text-2xs font-medium text-ink-700 dark:border-ink-800 dark:text-ink-300\">\n <Icon name={p} category=\"platform\" size={12} />\n {taxonomyLabel(\"platforms\", p)}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {category && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Category</h3>\n <a href={`/categories/${category}`} class=\"rounded-full bg-secondary px-2 py-0.5 text-2xs font-medium text-secondary-foreground no-underline\">\n {taxonomyLabel(\"categories\", category)}\n </a>\n </div>\n )}\n\n {tags.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Tags</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {tags.map((t) => (\n <li>\n <a href={`/${detail.slug}?tag=${encodeURIComponent(t)}`} rel=\"nofollow\" class=\"rounded-full border border-ink-200 px-2 py-0.5 text-2xs font-medium text-ink-700 no-underline dark:border-ink-800 dark:text-ink-300\">\n {taxonomyLabel(\"topics\", t)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {contributionSignals.length > 0 && (\n <div>\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Repository hygiene</h3>\n <ul class=\"m-0 flex list-none flex-col gap-1 p-0 text-sm\">\n {contributionSignals.map((s) => (\n <li class=\"inline-flex items-center gap-1.5 text-ink-700 dark:text-ink-200\">\n {s.ok ? (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-emerald-600 dark:text-emerald-400\">\n <path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" />\n </svg>\n ) : (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-ink-400\">\n <path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\" />\n </svg>\n )}\n {s.label}\n </li>\n ))}\n </ul>\n </div>\n )}\n </section>\n )}\n\n {/* ── Source card (small) ────────────────────────────────── */}\n {sidebar.showSource && (\n <section\n class=\"grove-card grove-card--muted rounded-[var(--radius-lg)] border border-dashed border-ink-200 bg-card/50 p-4 text-2xs text-ink-500 dark:border-ink-800 dark:text-ink-400\"\n aria-labelledby=\"sidebar-source-title\"\n >\n <h2\n id=\"sidebar-source-title\"\n class=\"grove-card-title m-0 mb-1.5 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Source\n </h2>\n {addedAtLabel && (\n <p class=\"m-0 leading-relaxed\">\n Added on <time datetime={String(record.addedAt)}>{addedAtLabel}</time>.\n </p>\n )}\n {/* Only when a curator actually reviewed the record. This line\n used to render unconditionally with an em dash where the date\n belongs, and gated the whole card besides. */}\n {reviewedAtLabel && (\n <p class:list={[\"m-0 leading-relaxed\", addedAtLabel && \"mt-1.5\"]}>\n Reviewed by {record.curation?.reviewedBy ?? \"grove\"}\n on <time datetime={String(record.curation?.reviewedAt)}>\n {reviewedAtLabel}\n </time>.\n </p>\n )}\n {alsoIn.length > 0 && (\n <p class=\"m-0 mt-1.5 leading-relaxed\">\n <span class=\"font-semibold\">Also in: </span>\n {alsoIn.map((c, i) => (\n <>\n <a href={c.url} class=\"text-inherit no-underline hover:underline\">{c.title}</a>{i < alsoIn.length - 1 ? \", \" : \"\"}\n </>\n ))}\n </p>\n )}\n {readingMetrics.wordCount > 0 && (\n <p class=\"m-0 mt-1 leading-relaxed\">\n Notes: {readingMetrics.wordCount.toLocaleString()} words · {readingMetrics.minutes} min read.\n </p>\n )}\n </section>\n )}\n</aside>",
|
|
370
370
|
"type": "registry:component",
|
|
371
371
|
"target": "~/src/components/grove/record-sidebar.astro"
|
|
372
372
|
},
|
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
},
|
|
403
403
|
{
|
|
404
404
|
"path": "default/components/grove/submission-client.astro",
|
|
405
|
-
"content": "---\nimport {\n inferStackFromTopics,\n parseGithubRepo,\n recordSlugify,\n yamlLines,\n yamlQuote,\n} from '@grove-dev/core';\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, recordSlugify, parseGithubRepo, yamlQuote, yamlLines, inferStackFromTopics }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n };\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = recordSlugify;\n const parseRepo = parseGithubRepo;\n const quote = yamlQuote;\n const lines = yamlLines;\n const inferStack = /** @param {GitHubRepo} repo */ (repo) =>\n inferStackFromTopics({ language: repo.language, topics: repo.topics });\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n const refresh = () => {\n const yaml = generateYaml();\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues[0], \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {GitHubRepo & { topics?: string[] }} */ (await response.json());\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) inputs.stack.value = inferStack(repository);\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
405
|
+
"content": "---\nimport {\n inferStackFromTopics,\n parseGithubRepo,\n recordSlugify,\n yamlLines,\n yamlQuote,\n} from '@grove-dev/core';\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, recordSlugify, parseGithubRepo, yamlQuote, yamlLines, inferStackFromTopics }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n };\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = recordSlugify;\n const parseRepo = parseGithubRepo;\n const quote = yamlQuote;\n const lines = yamlLines;\n const inferStack = /** @param {GitHubRepo} repo */ (repo) =>\n inferStackFromTopics({ language: repo.language, topics: repo.topics });\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n // The day the record joins the directory. Without it the\n // `recently-added` sort has nothing to sort a new record on and\n // drops it to the bottom of the list built to show it off.\n `addedAt: ${new Date().toISOString().slice(0, 10)}`,\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n const refresh = () => {\n const yaml = generateYaml();\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues[0], \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {GitHubRepo & { topics?: string[] }} */ (await response.json());\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) inputs.stack.value = inferStack(repository);\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
406
406
|
"type": "registry:component",
|
|
407
407
|
"target": "~/src/components/grove/submission-client.astro"
|
|
408
408
|
},
|
|
@@ -432,7 +432,8 @@
|
|
|
432
432
|
}
|
|
433
433
|
],
|
|
434
434
|
"meta": {
|
|
435
|
-
"version": "1.
|
|
435
|
+
"version": "1.1.0",
|
|
436
|
+
"requiresGrove": "0.10.0"
|
|
436
437
|
},
|
|
437
438
|
"type": "registry:block"
|
|
438
439
|
}
|
package/dist/r/home.json
CHANGED
package/dist/r/not-found.json
CHANGED
package/dist/r/project-card.json
CHANGED
package/dist/r/record.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"path": "default/components/grove/record-sidebar.astro",
|
|
26
|
-
"content": "---\nimport type { RecordDetailModel } from '@grove-dev/astro/server';\nimport { taxonomyLabel } from '@grove-dev/astro/server';\n/**\n * RecordSidebar.astro\n *\n * Sticky right-hand column on the record detail page. Renders\n * up to four cards, each conditional on the model's `sidebar`\n * visibility flags:\n *\n * - Activity — repo facts (stars, forks, language, license, …)\n * - Freshness — last commit / last fetch / maintenance status\n * - Ecosystem — stack, platforms, category, tags, hygiene files\n * - Source — curation metadata + reading-time summary\n *\n * Empty rows are suppressed entirely — the sidebar never shows \"—\"\n * or \"0\" placeholders that confuse \"no data\" with \"zero\".\n *\n * Sticky on lg+ (`lg:sticky lg:top-20 lg:max-h-calc(100vh-5rem)\n * lg:overflow-y-auto`) so the cards stay in view while the user\n * scrolls the body. Cards are individually rendered so the\n * sticky container's height is bounded by the actual content.\n */\nimport { licenseDisplay } from '@grove-dev/core';\nimport Badge from '../ui/badge.astro';\nimport Icon from './icon.astro';\nimport LanguageBreakdown from './language-breakdown.astro';\n\ninterface Props {\n detail: RecordDetailModel;\n /**\n * Pass false when a parent wrapper owns the sticky behavior (e.g.\n * the detail page stacks the TOC above this sidebar inside one\n * sticky column).\n */\n sticky?: boolean;\n /**\n * \"column\" (default) stacks the cards vertically for a rail;\n * \"grid\" lays them out in responsive columns for full-width\n * placement below the article.\n */\n layout?: 'column' | 'grid';\n}\n\nconst { detail, sticky = true, layout = 'column' } = Astro.props;\nconst {\n sidebar,\n github,\n stars,\n forks,\n language,\n licenseSpdx,\n pushedLabel,\n repoUrl,\n ownerRepo,\n healthLabel,\n activityBadge,\n stacks,\n platforms,\n tags,\n category,\n contributionSignals,\n languages,\n totalLanguageBytes,\n readingMetrics,\n record,\n firstCommitYear,\n lastFetchedLabel,\n reviewedAtLabel,\n} = detail;\nconst alsoIn: Array<{ url: string; title: string }> = detail.collectionMembership ?? [];\n\n// Visibility helpers for individual rows inside the Activity card.\n// `hasRepo` is the discriminator between \"GitHub data synced\" and\n// \"no data fetched yet\" — without it the card would show \"Stars 0\"\n// even when the field was never populated.\nconst repo = github;\nconst hasRepo = !!repo;\nconst starsNumber = typeof stars === 'number' && stars > 0 ? stars : null;\nconst forksNumber = typeof forks === 'number' && forks > 0 ? forks : null;\n// `repo` is a loosely-typed passthrough of the raw GitHub API response\n// (see `@grove-dev/astro/server`'s `getRecordDetailModel`) — `releases`\n// isn't in the normalized `githubMetadataSchema`, so it arrives as\n// `unknown` and needs a local shape for the three fields read below.\nconst recentReleases = (\n (repo?.releases as Array<{ html_url?: string; tag_name?: string; name?: string }> | undefined) ??\n []\n).slice(0, 1);\nconst isArchived = !!repo?.archived;\n\n// Render a kv row only when both the label and value have content.\nfunction row(label: string, value: unknown) {\n if (value === null || value === undefined || value === '') return null;\n return { label, value };\n}\n---\n\n<aside\n class:list={[\n layout === \"grid\"\n ? \"grove-sidebar grid grid-cols-1 items-start gap-4 sm:grid-cols-2 xl:grid-cols-4\"\n : \"grove-sidebar flex flex-col gap-4\",\n layout === \"column\" &&\n sticky &&\n \"lg:sticky lg:top-20 lg:max-h-[calc(100vh-5rem)] lg:self-start lg:overflow-y-auto\",\n ]}\n aria-label=\"Record metadata\"\n>\n\n {/* ── Activity card ──────────────────────────────────────── */}\n {sidebar.showActivity && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-activity-title\"\n >\n <h2\n id=\"sidebar-activity-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Activity\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {row(\"Stars\", starsNumber !== null ? starsNumber : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Stars</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{starsNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Forks\", forksNumber !== null ? forksNumber.toLocaleString() : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Forks</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{forksNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Contributors\", repo?.contributors_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Contributors</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.contributors_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Open issues\", repo?.open_issues_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Open issues</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.open_issues_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Watchers\", repo?.subscribers_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Watchers</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.subscribers_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Language\", language) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Language</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{language}</dd>\n </div>\n )}\n {row(\"License\", licenseSpdx) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">License</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{licenseDisplay(licenseSpdx)}</dd>\n </div>\n )}\n {row(\"Default branch\", repo?.default_branch) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Default branch</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{repo!.default_branch}</dd>\n </div>\n )}\n {row(\"First commit\", firstCommitYear) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">First commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo!.created_at)}>{firstCommitYear}</time>\n </dd>\n </div>\n )}\n {recentReleases[0] && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Latest release</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a\n href={recentReleases[0].html_url ?? repoUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"no-underline hover:underline\"\n >\n {recentReleases[0].tag_name ?? recentReleases[0].name ?? \"—\"}\n </a>\n </dd>\n </div>\n )}\n </dl>\n\n <LanguageBreakdown languages={languages} totalBytes={totalLanguageBytes} />\n </section>\n )}\n\n {/* ── Freshness card ─────────────────────────────────────── */}\n {sidebar.showFreshness && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-freshness-title\"\n >\n <h2\n id=\"sidebar-freshness-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Freshness\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {pushedLabel && pushedLabel !== \"—\" && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{pushedLabel}</dd>\n </div>\n )}\n {repo?.updated_at && lastFetchedLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last fetched</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo.updated_at)}>{lastFetchedLabel}</time>\n </dd>\n </div>\n )}\n {activityBadge && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Maintenance</dt>\n <dd>\n <span data-activity-tone={activityBadge.tone} class=\"grove-pill grove-pill--activity inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium\">\n {activityBadge.label}\n </span>\n </dd>\n </div>\n )}\n {healthLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Health</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{healthLabel}</dd>\n </div>\n )}\n {isArchived && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Status</dt>\n <dd><Badge variant=\"warning\">Archived</Badge></dd>\n </div>\n )}\n {repo?.homepage && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Docs</dt>\n <dd class=\"truncate text-ink-900 dark:text-ink-100\">\n <a href={String(repo.homepage)} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {new URL(String(repo.homepage)).hostname}\n </a>\n </dd>\n </div>\n )}\n {repoUrl && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Source</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a href={repoUrl} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {ownerRepo ? `${ownerRepo.owner}/${ownerRepo.repo}` : repoUrl}\n </a>\n </dd>\n </div>\n )}\n </dl>\n </section>\n )}\n\n {/* ── Ecosystem card ─────────────────────────────────────── */}\n {sidebar.showEcosystem && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-ecosystem-title\"\n >\n <h2\n id=\"sidebar-ecosystem-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Ecosystem\n </h2>\n\n {stacks.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Stack</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {stacks.map((s) => (\n <li>\n <a href={`/${detail.slug}?stack=${encodeURIComponent(s)}`} class=\"inline-flex items-center gap-1.5 rounded-full bg-secondary py-0.5 pl-1.5 pr-2 text-2xs font-medium text-secondary-foreground no-underline\">\n <Icon name={s} category=\"stack\" size={12} />\n {taxonomyLabel(\"stacks\", s)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {platforms.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Platforms</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {platforms.map((p) => (\n <li class=\"inline-flex items-center gap-1.5 rounded-full border border-ink-200 py-0.5 pl-1.5 pr-2 text-2xs font-medium text-ink-700 dark:border-ink-800 dark:text-ink-300\">\n <Icon name={p} category=\"platform\" size={12} />\n {taxonomyLabel(\"platforms\", p)}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {category && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Category</h3>\n <a href={`/${detail.slug}?category=${encodeURIComponent(category)}`} class=\"rounded-full bg-secondary px-2 py-0.5 text-2xs font-medium text-secondary-foreground no-underline\">\n {taxonomyLabel(\"categories\", category)}\n </a>\n </div>\n )}\n\n {tags.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Tags</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {tags.map((t) => (\n <li>\n <a href={`/${detail.slug}?tag=${encodeURIComponent(t)}`} class=\"rounded-full border border-ink-200 px-2 py-0.5 text-2xs font-medium text-ink-700 no-underline dark:border-ink-800 dark:text-ink-300\">\n {taxonomyLabel(\"topics\", t)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {contributionSignals.length > 0 && (\n <div>\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Repository hygiene</h3>\n <ul class=\"m-0 flex list-none flex-col gap-1 p-0 text-sm\">\n {contributionSignals.map((s) => (\n <li class=\"inline-flex items-center gap-1.5 text-ink-700 dark:text-ink-200\">\n {s.ok ? (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-emerald-600 dark:text-emerald-400\">\n <path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" />\n </svg>\n ) : (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-ink-400\">\n <path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\" />\n </svg>\n )}\n {s.label}\n </li>\n ))}\n </ul>\n </div>\n )}\n </section>\n )}\n\n {/* ── Source card (small) ────────────────────────────────── */}\n {sidebar.showSource && (\n <section\n class=\"grove-card grove-card--muted rounded-[var(--radius-lg)] border border-dashed border-ink-200 bg-card/50 p-4 text-2xs text-ink-500 dark:border-ink-800 dark:text-ink-400\"\n aria-labelledby=\"sidebar-source-title\"\n >\n <h2\n id=\"sidebar-source-title\"\n class=\"grove-card-title m-0 mb-1.5 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Source\n </h2>\n <p class=\"m-0 leading-relaxed\">\n Reviewed by {record.curation?.reviewedBy ?? \"grove\"}\n on <time datetime={String(record.curation?.reviewedAt)}>\n {reviewedAtLabel ?? \"—\"}\n </time>.\n </p>\n {alsoIn.length > 0 && (\n <p class=\"m-0 mt-1.5 leading-relaxed\">\n <span class=\"font-semibold\">Also in: </span>\n {alsoIn.map((c, i) => (\n <>\n <a href={c.url} class=\"text-inherit no-underline hover:underline\">{c.title}</a>{i < alsoIn.length - 1 ? \", \" : \"\"}\n </>\n ))}\n </p>\n )}\n {readingMetrics.wordCount > 0 && (\n <p class=\"m-0 mt-1 leading-relaxed\">\n Notes: {readingMetrics.wordCount.toLocaleString()} words · {readingMetrics.minutes} min read.\n </p>\n )}\n </section>\n )}\n</aside>",
|
|
26
|
+
"content": "---\nimport type { RecordDetailModel } from '@grove-dev/astro/server';\nimport { taxonomyLabel } from '@grove-dev/astro/server';\n/**\n * RecordSidebar.astro\n *\n * Sticky right-hand column on the record detail page. Renders\n * up to four cards, each conditional on the model's `sidebar`\n * visibility flags:\n *\n * - Activity — repo facts (stars, forks, language, license, …)\n * - Freshness — last commit / last fetch / maintenance status\n * - Ecosystem — stack, platforms, category, tags, hygiene files\n * - Source — curation metadata + reading-time summary\n *\n * Empty rows are suppressed entirely — the sidebar never shows \"—\"\n * or \"0\" placeholders that confuse \"no data\" with \"zero\".\n *\n * Sticky on lg+ (`lg:sticky lg:top-20 lg:max-h-calc(100vh-5rem)\n * lg:overflow-y-auto`) so the cards stay in view while the user\n * scrolls the body. Cards are individually rendered so the\n * sticky container's height is bounded by the actual content.\n */\nimport { licenseDisplay } from '@grove-dev/core';\nimport Badge from '../ui/badge.astro';\nimport Icon from './icon.astro';\nimport LanguageBreakdown from './language-breakdown.astro';\n\ninterface Props {\n detail: RecordDetailModel;\n /**\n * Pass false when a parent wrapper owns the sticky behavior (e.g.\n * the detail page stacks the TOC above this sidebar inside one\n * sticky column).\n */\n sticky?: boolean;\n /**\n * \"column\" (default) stacks the cards vertically for a rail;\n * \"grid\" lays them out in responsive columns for full-width\n * placement below the article.\n */\n layout?: 'column' | 'grid';\n}\n\nconst { detail, sticky = true, layout = 'column' } = Astro.props;\nconst {\n sidebar,\n github,\n stars,\n forks,\n language,\n licenseSpdx,\n pushedLabel,\n repoUrl,\n ownerRepo,\n healthLabel,\n activityBadge,\n stacks,\n platforms,\n tags,\n category,\n contributionSignals,\n languages,\n totalLanguageBytes,\n readingMetrics,\n record,\n firstCommitYear,\n lastFetchedLabel,\n reviewedAtLabel,\n addedAtLabel,\n} = detail;\nconst alsoIn: Array<{ url: string; title: string }> = detail.collectionMembership ?? [];\n\n// Visibility helpers for individual rows inside the Activity card.\n// `hasRepo` is the discriminator between \"GitHub data synced\" and\n// \"no data fetched yet\" — without it the card would show \"Stars 0\"\n// even when the field was never populated.\nconst repo = github;\nconst hasRepo = !!repo;\nconst starsNumber = typeof stars === 'number' && stars > 0 ? stars : null;\nconst forksNumber = typeof forks === 'number' && forks > 0 ? forks : null;\n// `repo` is a loosely-typed passthrough of the raw GitHub API response\n// (see `@grove-dev/astro/server`'s `getRecordDetailModel`) — `releases`\n// isn't in the normalized `githubMetadataSchema`, so it arrives as\n// `unknown` and needs a local shape for the three fields read below.\nconst recentReleases = (\n (repo?.releases as Array<{ html_url?: string; tag_name?: string; name?: string }> | undefined) ??\n []\n).slice(0, 1);\nconst isArchived = !!repo?.archived;\n\n// Render a kv row only when both the label and value have content.\nfunction row(label: string, value: unknown) {\n if (value === null || value === undefined || value === '') return null;\n return { label, value };\n}\n---\n\n<aside\n class:list={[\n layout === \"grid\"\n ? \"grove-sidebar grid grid-cols-1 items-start gap-4 sm:grid-cols-2 xl:grid-cols-4\"\n : \"grove-sidebar flex flex-col gap-4\",\n layout === \"column\" &&\n sticky &&\n \"lg:sticky lg:top-20 lg:max-h-[calc(100vh-5rem)] lg:self-start lg:overflow-y-auto\",\n ]}\n aria-label=\"Record metadata\"\n>\n\n {/* ── Activity card ──────────────────────────────────────── */}\n {sidebar.showActivity && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-activity-title\"\n >\n <h2\n id=\"sidebar-activity-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Activity\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {row(\"Stars\", starsNumber !== null ? starsNumber : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Stars</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{starsNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Forks\", forksNumber !== null ? forksNumber.toLocaleString() : null) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Forks</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{forksNumber!.toLocaleString()}</dd>\n </div>\n )}\n {row(\"Contributors\", repo?.contributors_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Contributors</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.contributors_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Open issues\", repo?.open_issues_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Open issues</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.open_issues_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Watchers\", repo?.subscribers_count) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Watchers</dt>\n <dd class=\"font-mono tabular-nums text-ink-900 dark:text-ink-100\">{Number(repo!.subscribers_count).toLocaleString()}</dd>\n </div>\n )}\n {row(\"Language\", language) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Language</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{language}</dd>\n </div>\n )}\n {row(\"License\", licenseSpdx) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">License</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{licenseDisplay(licenseSpdx)}</dd>\n </div>\n )}\n {row(\"Default branch\", repo?.default_branch) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Default branch</dt>\n <dd class=\"font-mono text-ink-900 dark:text-ink-100\">{repo!.default_branch}</dd>\n </div>\n )}\n {row(\"First commit\", firstCommitYear) && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">First commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo!.created_at)}>{firstCommitYear}</time>\n </dd>\n </div>\n )}\n {recentReleases[0] && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Latest release</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a\n href={recentReleases[0].html_url ?? repoUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n class=\"no-underline hover:underline\"\n >\n {recentReleases[0].tag_name ?? recentReleases[0].name ?? \"—\"}\n </a>\n </dd>\n </div>\n )}\n </dl>\n\n <LanguageBreakdown languages={languages} totalBytes={totalLanguageBytes} />\n </section>\n )}\n\n {/* ── Freshness card ─────────────────────────────────────── */}\n {sidebar.showFreshness && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-freshness-title\"\n >\n <h2\n id=\"sidebar-freshness-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Freshness\n </h2>\n <dl class=\"grove-kv m-0 flex flex-col gap-2.5 text-sm\">\n {pushedLabel && pushedLabel !== \"—\" && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last commit</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{pushedLabel}</dd>\n </div>\n )}\n {repo?.updated_at && lastFetchedLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Last fetched</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <time datetime={String(repo.updated_at)}>{lastFetchedLabel}</time>\n </dd>\n </div>\n )}\n {activityBadge && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Maintenance</dt>\n <dd>\n <span data-activity-tone={activityBadge.tone} class=\"grove-pill grove-pill--activity inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium\">\n {activityBadge.label}\n </span>\n </dd>\n </div>\n )}\n {healthLabel && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Health</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">{healthLabel}</dd>\n </div>\n )}\n {isArchived && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Status</dt>\n <dd><Badge variant=\"warning\">Archived</Badge></dd>\n </div>\n )}\n {repo?.homepage && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Docs</dt>\n <dd class=\"truncate text-ink-900 dark:text-ink-100\">\n <a href={String(repo.homepage)} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {new URL(String(repo.homepage)).hostname}\n </a>\n </dd>\n </div>\n )}\n {repoUrl && (\n <div class=\"flex items-baseline justify-between gap-3\">\n <dt class=\"text-ink-500 dark:text-ink-400\">Source</dt>\n <dd class=\"text-ink-900 dark:text-ink-100\">\n <a href={repoUrl} target=\"_blank\" rel=\"noopener noreferrer\" class=\"no-underline hover:underline\">\n {ownerRepo ? `${ownerRepo.owner}/${ownerRepo.repo}` : repoUrl}\n </a>\n </dd>\n </div>\n )}\n </dl>\n </section>\n )}\n\n {/* ── Ecosystem card ─────────────────────────────────────── */}\n {sidebar.showEcosystem && (\n <section\n class=\"grove-card rounded-[var(--radius-lg)] border border-ink-200 bg-card p-4 dark:border-ink-800\"\n aria-labelledby=\"sidebar-ecosystem-title\"\n >\n <h2\n id=\"sidebar-ecosystem-title\"\n class=\"grove-card-title m-0 mb-3 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Ecosystem\n </h2>\n\n {stacks.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Stack</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {stacks.map((s) => (\n <li>\n <a href={`/stacks/${s}`} class=\"inline-flex items-center gap-1.5 rounded-full bg-secondary py-0.5 pl-1.5 pr-2 text-2xs font-medium text-secondary-foreground no-underline\">\n <Icon name={s} category=\"stack\" size={12} />\n {taxonomyLabel(\"stacks\", s)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {platforms.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Platforms</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {platforms.map((p) => (\n <li class=\"inline-flex items-center gap-1.5 rounded-full border border-ink-200 py-0.5 pl-1.5 pr-2 text-2xs font-medium text-ink-700 dark:border-ink-800 dark:text-ink-300\">\n <Icon name={p} category=\"platform\" size={12} />\n {taxonomyLabel(\"platforms\", p)}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {category && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Category</h3>\n <a href={`/categories/${category}`} class=\"rounded-full bg-secondary px-2 py-0.5 text-2xs font-medium text-secondary-foreground no-underline\">\n {taxonomyLabel(\"categories\", category)}\n </a>\n </div>\n )}\n\n {tags.length > 0 && (\n <div class=\"mb-3\">\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Tags</h3>\n <ul class=\"m-0 flex list-none flex-wrap gap-1.5 p-0\">\n {tags.map((t) => (\n <li>\n <a href={`/${detail.slug}?tag=${encodeURIComponent(t)}`} rel=\"nofollow\" class=\"rounded-full border border-ink-200 px-2 py-0.5 text-2xs font-medium text-ink-700 no-underline dark:border-ink-800 dark:text-ink-300\">\n {taxonomyLabel(\"topics\", t)}\n </a>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {contributionSignals.length > 0 && (\n <div>\n <h3 class=\"m-0 mb-1.5 text-2xs font-medium uppercase tracking-wider text-ink-500 dark:text-ink-400\">Repository hygiene</h3>\n <ul class=\"m-0 flex list-none flex-col gap-1 p-0 text-sm\">\n {contributionSignals.map((s) => (\n <li class=\"inline-flex items-center gap-1.5 text-ink-700 dark:text-ink-200\">\n {s.ok ? (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-emerald-600 dark:text-emerald-400\">\n <path d=\"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 0 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z\" />\n </svg>\n ) : (\n <svg viewBox=\"0 0 16 16\" width=\"11\" height=\"11\" aria-hidden=\"true\" fill=\"currentColor\" class=\"text-ink-400\">\n <path d=\"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z\" />\n </svg>\n )}\n {s.label}\n </li>\n ))}\n </ul>\n </div>\n )}\n </section>\n )}\n\n {/* ── Source card (small) ────────────────────────────────── */}\n {sidebar.showSource && (\n <section\n class=\"grove-card grove-card--muted rounded-[var(--radius-lg)] border border-dashed border-ink-200 bg-card/50 p-4 text-2xs text-ink-500 dark:border-ink-800 dark:text-ink-400\"\n aria-labelledby=\"sidebar-source-title\"\n >\n <h2\n id=\"sidebar-source-title\"\n class=\"grove-card-title m-0 mb-1.5 text-2xs font-semibold uppercase tracking-wider text-ink-500 dark:text-ink-400\"\n >\n Source\n </h2>\n {addedAtLabel && (\n <p class=\"m-0 leading-relaxed\">\n Added on <time datetime={String(record.addedAt)}>{addedAtLabel}</time>.\n </p>\n )}\n {/* Only when a curator actually reviewed the record. This line\n used to render unconditionally with an em dash where the date\n belongs, and gated the whole card besides. */}\n {reviewedAtLabel && (\n <p class:list={[\"m-0 leading-relaxed\", addedAtLabel && \"mt-1.5\"]}>\n Reviewed by {record.curation?.reviewedBy ?? \"grove\"}\n on <time datetime={String(record.curation?.reviewedAt)}>\n {reviewedAtLabel}\n </time>.\n </p>\n )}\n {alsoIn.length > 0 && (\n <p class=\"m-0 mt-1.5 leading-relaxed\">\n <span class=\"font-semibold\">Also in: </span>\n {alsoIn.map((c, i) => (\n <>\n <a href={c.url} class=\"text-inherit no-underline hover:underline\">{c.title}</a>{i < alsoIn.length - 1 ? \", \" : \"\"}\n </>\n ))}\n </p>\n )}\n {readingMetrics.wordCount > 0 && (\n <p class=\"m-0 mt-1 leading-relaxed\">\n Notes: {readingMetrics.wordCount.toLocaleString()} words · {readingMetrics.minutes} min read.\n </p>\n )}\n </section>\n )}\n</aside>",
|
|
27
27
|
"type": "registry:component",
|
|
28
28
|
"target": "~/src/components/grove/record-sidebar.astro"
|
|
29
29
|
},
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
55
|
"meta": {
|
|
56
|
-
"version": "1.
|
|
56
|
+
"version": "1.1.0",
|
|
57
|
+
"requiresGrove": "0.10.0"
|
|
57
58
|
},
|
|
58
59
|
"type": "registry:block"
|
|
59
60
|
}
|
package/dist/r/registry.json
CHANGED
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
}
|
|
47
47
|
],
|
|
48
48
|
"meta": {
|
|
49
|
-
"version": "1.
|
|
49
|
+
"version": "1.1.0",
|
|
50
|
+
"requiresGrove": "0.10.0"
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
{
|
|
@@ -111,7 +112,8 @@
|
|
|
111
112
|
}
|
|
112
113
|
],
|
|
113
114
|
"meta": {
|
|
114
|
-
"version": "1.
|
|
115
|
+
"version": "1.1.0",
|
|
116
|
+
"requiresGrove": "0.10.0"
|
|
115
117
|
}
|
|
116
118
|
},
|
|
117
119
|
{
|
|
@@ -152,7 +154,8 @@
|
|
|
152
154
|
}
|
|
153
155
|
],
|
|
154
156
|
"meta": {
|
|
155
|
-
"version": "1.
|
|
157
|
+
"version": "1.1.0",
|
|
158
|
+
"requiresGrove": "0.10.0"
|
|
156
159
|
}
|
|
157
160
|
},
|
|
158
161
|
{
|
|
@@ -208,7 +211,8 @@
|
|
|
208
211
|
}
|
|
209
212
|
],
|
|
210
213
|
"meta": {
|
|
211
|
-
"version": "1.
|
|
214
|
+
"version": "1.1.0",
|
|
215
|
+
"requiresGrove": "0.10.0"
|
|
212
216
|
}
|
|
213
217
|
},
|
|
214
218
|
{
|
|
@@ -259,7 +263,8 @@
|
|
|
259
263
|
}
|
|
260
264
|
],
|
|
261
265
|
"meta": {
|
|
262
|
-
"version": "1.
|
|
266
|
+
"version": "1.1.0",
|
|
267
|
+
"requiresGrove": "0.10.0"
|
|
263
268
|
}
|
|
264
269
|
},
|
|
265
270
|
{
|
|
@@ -317,7 +322,8 @@
|
|
|
317
322
|
}
|
|
318
323
|
],
|
|
319
324
|
"meta": {
|
|
320
|
-
"version": "1.
|
|
325
|
+
"version": "1.1.0",
|
|
326
|
+
"requiresGrove": "0.10.0"
|
|
321
327
|
}
|
|
322
328
|
},
|
|
323
329
|
{
|
|
@@ -393,7 +399,8 @@
|
|
|
393
399
|
}
|
|
394
400
|
],
|
|
395
401
|
"meta": {
|
|
396
|
-
"version": "1.
|
|
402
|
+
"version": "1.1.0",
|
|
403
|
+
"requiresGrove": "0.10.0"
|
|
397
404
|
}
|
|
398
405
|
},
|
|
399
406
|
{
|
|
@@ -444,7 +451,8 @@
|
|
|
444
451
|
}
|
|
445
452
|
],
|
|
446
453
|
"meta": {
|
|
447
|
-
"version": "1.
|
|
454
|
+
"version": "1.1.0",
|
|
455
|
+
"requiresGrove": "0.10.0"
|
|
448
456
|
}
|
|
449
457
|
},
|
|
450
458
|
{
|
|
@@ -469,7 +477,8 @@
|
|
|
469
477
|
}
|
|
470
478
|
],
|
|
471
479
|
"meta": {
|
|
472
|
-
"version": "1.
|
|
480
|
+
"version": "1.1.0",
|
|
481
|
+
"requiresGrove": "0.10.0"
|
|
473
482
|
}
|
|
474
483
|
},
|
|
475
484
|
{
|
|
@@ -489,7 +498,8 @@
|
|
|
489
498
|
}
|
|
490
499
|
],
|
|
491
500
|
"meta": {
|
|
492
|
-
"version": "1.
|
|
501
|
+
"version": "1.1.0",
|
|
502
|
+
"requiresGrove": "0.10.0"
|
|
493
503
|
}
|
|
494
504
|
},
|
|
495
505
|
{
|
|
@@ -509,7 +519,8 @@
|
|
|
509
519
|
}
|
|
510
520
|
],
|
|
511
521
|
"meta": {
|
|
512
|
-
"version": "1.
|
|
522
|
+
"version": "1.1.0",
|
|
523
|
+
"requiresGrove": "0.10.0"
|
|
513
524
|
}
|
|
514
525
|
},
|
|
515
526
|
{
|
|
@@ -529,7 +540,8 @@
|
|
|
529
540
|
}
|
|
530
541
|
],
|
|
531
542
|
"meta": {
|
|
532
|
-
"version": "1.
|
|
543
|
+
"version": "1.1.0",
|
|
544
|
+
"requiresGrove": "0.10.0"
|
|
533
545
|
}
|
|
534
546
|
},
|
|
535
547
|
{
|
|
@@ -896,7 +908,8 @@
|
|
|
896
908
|
}
|
|
897
909
|
],
|
|
898
910
|
"meta": {
|
|
899
|
-
"version": "1.
|
|
911
|
+
"version": "1.1.0",
|
|
912
|
+
"requiresGrove": "0.10.0"
|
|
900
913
|
}
|
|
901
914
|
}
|
|
902
915
|
]
|
package/dist/r/shell.json
CHANGED
package/dist/r/submit.json
CHANGED
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"path": "default/components/grove/submission-client.astro",
|
|
19
|
-
"content": "---\nimport {\n inferStackFromTopics,\n parseGithubRepo,\n recordSlugify,\n yamlLines,\n yamlQuote,\n} from '@grove-dev/core';\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, recordSlugify, parseGithubRepo, yamlQuote, yamlLines, inferStackFromTopics }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n };\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = recordSlugify;\n const parseRepo = parseGithubRepo;\n const quote = yamlQuote;\n const lines = yamlLines;\n const inferStack = /** @param {GitHubRepo} repo */ (repo) =>\n inferStackFromTopics({ language: repo.language, topics: repo.topics });\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n const refresh = () => {\n const yaml = generateYaml();\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues[0], \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {GitHubRepo & { topics?: string[] }} */ (await response.json());\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) inputs.stack.value = inferStack(repository);\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
19
|
+
"content": "---\nimport {\n inferStackFromTopics,\n parseGithubRepo,\n recordSlugify,\n yamlLines,\n yamlQuote,\n} from '@grove-dev/core';\n\ninterface Props {\n existingSlugs: string[];\n existingFullNames: string[];\n repoUrl: string;\n fields: {\n category: boolean;\n stack: boolean;\n platforms: boolean;\n tags: boolean;\n license?: boolean;\n };\n /** Taxonomy ids for client-side validation. */\n taxonomy?: {\n categoryIds?: string[];\n stackIds?: string[];\n platformIds?: string[];\n };\n /**\n * Optional path of a server-side proxy endpoint that wraps\n * `api.github.com` (SSR consumers with an adapter can wire one and\n * read a `GITHUB_TOKEN` env var to lift the rate limit). When\n * omitted — the static-build default — the visitor's browser calls\n * `https://api.github.com/repos/{owner}/{repo}` directly, which\n * works on any static host but is subject to GitHub's per-IP\n * unauthenticated limit (60 requests/hour).\n */\n githubProxyPath?: string;\n}\nconst {\n existingSlugs,\n existingFullNames,\n repoUrl,\n fields,\n taxonomy,\n githubProxyPath = '',\n} = Astro.props;\n---\n\n<script is:inline define:vars={{ existingSlugs, existingFullNames, repoUrl, fields, taxonomy, githubProxyPath, recordSlugify, parseGithubRepo, yamlQuote, yamlLines, inferStackFromTopics }}>\n /** @typedef {{ name: string; description: string | null; html_url: string; homepage: string | null; language: string | null; private: boolean; topics: string[] }} GitHubRepo */\n /** @type {GitHubRepo | null} */\n let repository = null;\n\n const $ = /** @param {string} selector */ (selector) => /** @type {HTMLElement | null} */ (document.querySelector(selector));\n /** @type {Record<string, HTMLInputElement | HTMLTextAreaElement | null>} */\n const inputs = {\n repo: /** @type {HTMLInputElement | null} */ ($(\"#repo-url\")),\n name: /** @type {HTMLInputElement | null} */ ($(\"#item-name\")),\n slug: /** @type {HTMLInputElement | null} */ ($(\"#item-slug\")),\n description: /** @type {HTMLInputElement | null} */ ($(\"#item-description\")),\n category: /** @type {HTMLSelectElement | null} */ ($(\"#item-category\")),\n stack: /** @type {HTMLSelectElement | null} */ ($(\"#primary-stack\")),\n tags: /** @type {HTMLInputElement | null} */ ($(\"#item-tags\")),\n license: /** @type {HTMLSelectElement | null} */ ($(\"#item-license\")),\n website: /** @type {HTMLInputElement | null} */ ($(\"#item-website\")),\n bestFor: /** @type {HTMLTextAreaElement | null} */ ($(\"#best-for\")),\n };\n const fetchButton = /** @type {HTMLButtonElement | null} */ ($(\"#fetch-repo\"));\n const preview = /** @type {HTMLElement | null} */ ($(\"#yaml-preview\"));\n const status = /** @type {HTMLElement | null} */ ($(\"#submit-status\"));\n const copyButton = /** @type {HTMLButtonElement | null} */ ($(\"#copy-yaml\"));\n const openPrLink = /** @type {HTMLAnchorElement | null} */ ($(\"#open-pr-link\"));\n const slugSet = new Set(existingSlugs);\n const repoSet = new Set(existingFullNames);\n const categoryIds = new Set(taxonomy?.categoryIds ?? []);\n const stackIds = new Set(taxonomy?.stackIds ?? []);\n const platformIds = new Set(taxonomy?.platformIds ?? []);\n\n const slugify = recordSlugify;\n const parseRepo = parseGithubRepo;\n const quote = yamlQuote;\n const lines = yamlLines;\n const inferStack = /** @param {GitHubRepo} repo */ (repo) =>\n inferStackFromTopics({ language: repo.language, topics: repo.topics });\n const selectedPlatforms = () =>\n /** @type {string[]} */ ([...document.querySelectorAll(\"input[name=platform]:checked\")].map((input) => /** @type {HTMLInputElement} */ (input).value));\n const setStatus = (text, tone = \"muted\") => {\n if (!status) return;\n status.textContent = text;\n // Status tokens (danger/warning/success) so the submit states use\n // the same semantic roles as the rest of the system.\n status.className = `mt-3 min-h-5 text-2xs ${tone === \"error\" ? \"text-danger\" : tone === \"warn\" ? \"text-warning\" : tone === \"success\" ? \"text-success\" : \"text-muted-foreground\"}`;\n };\n const generateYaml = () => {\n if (!repository) return \"\";\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return \"\";\n const tags = String(inputs.tags?.value ?? \"\").split(\",\").map((tag) => tag.trim()).filter(Boolean);\n const platforms = selectedPlatforms();\n const bestFor = String(inputs.bestFor?.value ?? \"\").split(\"\\n\").map((item) => item.trim()).filter(Boolean);\n return [\n \"kind: project\",\n `slug: ${slugify(inputs.slug?.value ?? repository.name)}`,\n // The day the record joins the directory. Without it the\n // `recently-added` sort has nothing to sort a new record on and\n // drops it to the bottom of the list built to show it off.\n `addedAt: ${new Date().toISOString().slice(0, 10)}`,\n `name: ${quote(inputs.name?.value ?? \"\")}`,\n `description: ${quote(inputs.description?.value ?? \"\")}`,\n ...(fields.category ? [`category: ${inputs.category?.value || \"uncategorized\"}`] : []),\n \"projectType: real-app\",\n ...(fields.stack && inputs.stack?.value ? [`stack: ${quote(inputs.stack.value)}`] : []),\n ...(fields.platforms ? [\"platforms:\", platforms.length ? lines(platforms) : \" []\"] : []),\n ...(fields.tags ? [\"tags:\", tags.length ? lines(tags) : \" []\"] : []),\n ...(fields.license && inputs.license?.value ? [\"licenses:\", lines([inputs.license.value])] : []),\n `repoUrl: ${repository.html_url}`,\n \"links:\",\n ` github: ${repository.html_url}`,\n ...(inputs.website?.value ? [` website: ${inputs.website.value}`] : []),\n \"bestFor:\", bestFor.length ? lines(bestFor) : \" []\",\n \"source:\",\n \" type: manual\",\n ` owner: ${parsed.owner}`,\n ` repo: ${parsed.repo}`,\n \"curation:\",\n \" reviewed: false\",\n \" labels: []\",\n \" lenses: []\",\n \"\",\n ].join(\"\\n\");\n };\n // NOTE: this taxonomy/slug membership logic duplicates a concern\n // that belongs in `@grove-dev/core` (domain/taxonomy rules, not\n // UI), but it can't be moved into an import here. This `<script>`\n // uses `define:vars` (see the tag above), which Astro's compiler\n // implicitly treats as `is:inline` — the script is emitted\n // verbatim into the page and is NOT run through Vite's bundler,\n // so a bare-specifier `import ... from \"@grove-dev/core\"` would\n // not resolve in the browser (no bundler rewrite, no import map).\n // `define:vars` itself only hands the script JSON-serializable\n // data (see `taxonomy`, `existingSlugs`, etc. above) — a function\n // reference can't cross that boundary either. Moving this out\n // would require converting the script off `is:inline`/`define:vars`\n // to a regular bundled `<script>` that reads its props from\n // `data-*` attributes or a JSON island, which is a larger\n // structural change than this fix warrants.\n const validationIssues = () => {\n const issues = [];\n if (inputs.slug && slugSet.has(slugify(inputs.slug.value))) {\n issues.push(\"A record with that slug already exists — update the existing one instead of opening a duplicate PR.\");\n }\n const description = String(inputs.description?.value ?? \"\");\n if (description.trim().length < 40) {\n issues.push(\"Description must be at least 40 characters.\");\n }\n if (fields.category && inputs.category) {\n const v = inputs.category.value;\n if (!v || v === \"uncategorized\" || (categoryIds.size > 0 && !categoryIds.has(v))) {\n issues.push(\"Choose a category from the taxonomy.\");\n }\n }\n if (fields.stack && inputs.stack) {\n const v = inputs.stack.value;\n if (!v || (stackIds.size > 0 && !stackIds.has(v))) {\n issues.push(\"Choose a primary stack from the taxonomy.\");\n }\n }\n if (fields.platforms && selectedPlatforms().length === 0) {\n issues.push(\"Select at least one platform.\");\n } else if (fields.platforms && platformIds.size > 0) {\n const bad = selectedPlatforms().find((p) => !platformIds.has(p));\n if (bad) issues.push(`Platform \"${bad}\" is not in the taxonomy.`);\n }\n return issues;\n };\n const refresh = () => {\n const yaml = generateYaml();\n if (preview) preview.textContent = yaml || \"Paste a GitHub URL to generate a draft.\";\n if (!yaml || !openPrLink || !copyButton) return;\n const issues = validationIssues();\n if (issues.length > 0) {\n setStatus(issues[0], \"error\");\n openPrLink.classList.add(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = true;\n copyButton.classList.add(\"pointer-events-none\", \"opacity-50\");\n return;\n }\n const params = new URLSearchParams({ filename: `data/records/${slugify(inputs.slug?.value ?? \"\")}.yml`, value: yaml });\n openPrLink.href = `${repoUrl}/new/main?${params}`;\n openPrLink.classList.remove(\"pointer-events-none\", \"opacity-50\");\n copyButton.disabled = false;\n copyButton.classList.remove(\"pointer-events-none\", \"opacity-50\");\n };\n\n fetchButton?.addEventListener(\"click\", async () => {\n const parsed = parseRepo(inputs.repo?.value ?? \"\");\n if (!parsed) return setStatus(\"Enter a valid GitHub repository URL.\", \"error\");\n const fullName = `${parsed.owner}/${parsed.repo}`.toLowerCase();\n if (repoSet.has(fullName)) setStatus(\"This repository is already listed. The draft can update its record.\", \"warn\");\n if (fetchButton) fetchButton.disabled = true;\n setStatus(\"Fetching GitHub metadata...\");\n try {\n if (githubProxyPath) {\n // Server-side proxy (SSR consumers) — the endpoint reads an\n // optional `GITHUB_TOKEN` env var and forwards the request\n // with a Bearer header (or unauthenticated, if no token).\n const proxyUrl = `${githubProxyPath}?owner=${encodeURIComponent(parsed.owner)}&repo=${encodeURIComponent(parsed.repo)}`;\n const response = await fetch(proxyUrl);\n const payload = /** @type {{ ok: boolean; status?: number; message?: string; data?: GitHubRepo }} */ (await response.json());\n if (!response.ok || !payload.ok || !payload.data) {\n throw new Error(payload.message || `GitHub returned ${response.status}.`);\n }\n repository = payload.data;\n } else {\n // Static-build default — call api.github.com directly. The\n // raw payload carries the same field names the form fill\n // logic consumes (name, description, html_url, homepage,\n // language, private, topics).\n const response = await fetch(\n `https://api.github.com/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`,\n { headers: { Accept: \"application/vnd.github+json\" } },\n );\n if (response.status === 404) {\n throw new Error(\"Repository not found or not public.\");\n }\n if (response.status === 403 || response.status === 429) {\n throw new Error(\n \"GitHub rate limit reached (60 requests/hour per visitor). Try again later or fill the fields manually.\",\n );\n }\n if (!response.ok) {\n throw new Error(`GitHub returned ${response.status}.`);\n }\n const data = /** @type {GitHubRepo & { topics?: string[] }} */ (await response.json());\n repository = {\n name: data.name,\n description: data.description ?? null,\n html_url: data.html_url,\n homepage: data.homepage ?? null,\n language: data.language ?? null,\n private: Boolean(data.private),\n topics: Array.isArray(data.topics) ? data.topics : [],\n };\n }\n if (repository.private) throw new Error(\"Private repositories cannot be submitted.\");\n if (inputs.name) inputs.name.value = repository.name || parsed.repo;\n if (inputs.slug) inputs.slug.value = slugify(repository.name || parsed.repo);\n if (inputs.description) inputs.description.value = repository.description || \"\";\n if (inputs.stack) inputs.stack.value = inferStack(repository);\n if (inputs.tags) inputs.tags.value = (repository.topics || []).slice(0, 8).join(\", \");\n if (inputs.website) inputs.website.value = repository.homepage || \"\";\n const duplicate = inputs.slug ? slugSet.has(inputs.slug.value) : false;\n setStatus(\n duplicate ? \"That slug already exists. Choose another or update the existing record.\" : \"Draft generated. Edit any field and the YAML will refresh.\",\n duplicate ? \"warn\" : \"success\",\n );\n refresh();\n } catch (error) {\n repository = null;\n setStatus(error instanceof Error ? error.message : \"Unable to fetch repository metadata.\", \"error\");\n } finally {\n if (fetchButton) fetchButton.disabled = false;\n }\n });\n $(\"#submit-form\")?.addEventListener(\"input\", refresh);\n $(\"#submit-form\")?.addEventListener(\"change\", refresh);\n copyButton?.addEventListener(\"click\", async () => {\n try {\n await navigator.clipboard.writeText(preview?.textContent || \"\");\n setStatus(\"Copied YAML to clipboard.\", \"success\");\n } catch {\n setStatus(\"Couldn't copy automatically. Select the YAML and copy it.\", \"error\");\n }\n });\n </script>\n",
|
|
20
20
|
"type": "registry:component",
|
|
21
21
|
"target": "~/src/components/grove/submission-client.astro"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
24
|
"meta": {
|
|
25
|
-
"version": "1.
|
|
25
|
+
"version": "1.1.0",
|
|
26
|
+
"requiresGrove": "0.10.0"
|
|
26
27
|
},
|
|
27
28
|
"type": "registry:block"
|
|
28
29
|
}
|