@grove-dev/astro 0.18.0 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG9C,cAAc,iBAAiB,CAAC;AAMhC,cAAc,gBAAgB,CAAC;AAU/B,MAAM,CAAC,OAAO,UAAU,UAAU,IAAI,gBAAgB,CAwFrD;AAID,eAAO,MAAM,sBAAsB,sCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAG9C,cAAc,iBAAiB,CAAC;AAMhC,cAAc,gBAAgB,CAAC;AAQ/B,MAAM,CAAC,OAAO,UAAU,UAAU,IAAI,gBAAgB,CAwFrD;AAID,eAAO,MAAM,sBAAsB,sCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * and nothing happened" surprise.
26
26
  */
27
27
  import { existsSync } from 'node:fs';
28
- import { dirname, resolve } from 'node:path';
28
+ import { resolve } from 'node:path';
29
29
  import { fileURLToPath } from 'node:url';
30
30
  import { loadConfig, prepareDirectory } from '@grove-dev/core';
31
31
  import { syncPackagedIcons } from './lib/packaged-icons.js';
@@ -35,7 +35,6 @@ export * from '@grove-dev/core';
35
35
  // counts, and pretty-print display maps. All dependency-free and
36
36
  // typed against `@grove-dev/core`.
37
37
  export * from './lib/index.js';
38
- const here = dirname(fileURLToPath(import.meta.url));
39
38
  // Virtual module id used to inject the consumer's `src/styles/global.css`.
40
39
  // Resolved by the inline Vite plugin below to the absolute file path
41
40
  // when the file exists, or to an empty module when it doesn't.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"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
2
2
  "name": "@grove-dev/astro",
3
- "version": "0.18.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "description": "Astro integration + server view-models for Grove directories. UI ships from @grove-dev/registry, not from this package.",
6
6
  "license": "MIT",
@@ -49,9 +49,9 @@
49
49
  "dependencies": {
50
50
  "marked": "^18.0.0",
51
51
  "sanitize-html": "^2.17.7",
52
- "shiki": "^1.29.2",
52
+ "shiki": "^4.4.3",
53
53
  "yaml": "^2.9.0",
54
- "@grove-dev/core": "0.18.0"
54
+ "@grove-dev/core": "1.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "astro": "^6.0.0 || ^7.0.0"
package/src/index.ts CHANGED
@@ -25,7 +25,7 @@
25
25
  * and nothing happened" surprise.
26
26
  */
27
27
  import { existsSync } from 'node:fs';
28
- import { dirname, resolve } from 'node:path';
28
+ import { resolve } from 'node:path';
29
29
  import { fileURLToPath } from 'node:url';
30
30
  import { loadConfig, prepareDirectory } from '@grove-dev/core';
31
31
  import type { AstroIntegration } from 'astro';
@@ -39,8 +39,6 @@ export * from '@grove-dev/core';
39
39
  // typed against `@grove-dev/core`.
40
40
  export * from './lib/index.js';
41
41
 
42
- const here = dirname(fileURLToPath(import.meta.url));
43
-
44
42
  // Virtual module id used to inject the consumer's `src/styles/global.css`.
45
43
  // Resolved by the inline Vite plugin below to the absolute file path
46
44
  // when the file exists, or to an empty module when it doesn't.
@@ -66,9 +66,6 @@ export interface CollectionPageModel {
66
66
  total: number;
67
67
  isEmpty: boolean;
68
68
  entries: CollectionEntry[];
69
- /** CollectionPage + ItemList + BreadcrumbList JSON-LD nodes. Ships
70
- * through `seo.jsonLd`; kept here too for backward compatibility. */
71
- jsonLd?: unknown;
72
69
  /** Complete head block: honors the collection's `seo.title`,
73
70
  * `seo.description`, and `seo.index` overrides. Pass to BaseLayout. */
74
71
  seo: PageSeo;
@@ -194,7 +191,6 @@ export function getCollectionPageModel(
194
191
  isEmpty: result.isEmpty,
195
192
  entries: result.entries,
196
193
  related,
197
- jsonLd,
198
194
  seo,
199
195
  };
200
196
  }
@@ -475,3 +471,83 @@ export function getRecordContextModel(
475
471
 
476
472
  return { relations, relatedRecords, collectionMembership };
477
473
  }
474
+
475
+ // ── Collection tiles ────────────────────────────────────────────
476
+
477
+ /** One collection as a card: what the index and "related" rows render. */
478
+ export interface CollectionTile {
479
+ slug: string;
480
+ url: string;
481
+ title: string;
482
+ /** First sentence of the editorial introduction, else the description. */
483
+ takeaway: string;
484
+ /** True when a curator wrote a note for at least one entry. */
485
+ editorial: boolean;
486
+ kind: 'curated' | 'generated';
487
+ count: number;
488
+ countLabel: string;
489
+ /** Up to eight entries with an image, in collection order. */
490
+ faces: Array<{ title: string; avatarUrl?: string }>;
491
+ /** First entries, for "Includes …" lines and quick picks. */
492
+ examples: Array<{
493
+ slug: string;
494
+ title: string;
495
+ url: string;
496
+ note?: string;
497
+ avatarUrl?: string;
498
+ stars?: number;
499
+ }>;
500
+ /** ISO date of the last editorial review, when the collection has one. */
501
+ reviewedAt?: string;
502
+ isEmpty: boolean;
503
+ }
504
+
505
+ function firstSentence(text: string | undefined): string | undefined {
506
+ const clean = text?.trim().replace(/\s+/g, ' ');
507
+ if (!clean) return undefined;
508
+ const match = clean.match(/^.+?[.!?](?=\s|$)/);
509
+ return match ? match[0] : clean;
510
+ }
511
+
512
+ /**
513
+ * Cards for `collections`, in the order given. `countNoun` defaults to
514
+ * the site's blueprint labels.
515
+ */
516
+ export function getCollectionTiles(
517
+ collections: Collection[],
518
+ entries: CollectionEntry[],
519
+ site?: { blueprintConfig?: { labelSingular?: string; labelPlural?: string } },
520
+ ): CollectionTile[] {
521
+ const singular = site?.blueprintConfig?.labelSingular ?? 'item';
522
+ const plural = site?.blueprintConfig?.labelPlural ?? 'items';
523
+ return collections.map((collection) => {
524
+ const result = runCollection(collection, entries);
525
+ const count = result.entries.length;
526
+ return {
527
+ slug: collection.slug,
528
+ url: `/collections/${collection.slug}/`,
529
+ title: collection.title,
530
+ takeaway: firstSentence(collection.editorial?.introduction) ?? collection.description,
531
+ editorial: result.entries.some((entry) => Boolean(entry.note)),
532
+ kind: collection.kind,
533
+ count,
534
+ countLabel: `${count} ${count === 1 ? singular : plural}`,
535
+ faces: result.entries
536
+ .filter((entry) => entry.avatarUrl)
537
+ .slice(0, 8)
538
+ .map((entry) => ({ title: entry.title, avatarUrl: entry.avatarUrl })),
539
+ examples: result.entries.slice(0, 4).map((entry) => ({
540
+ slug: entry.slug,
541
+ title: entry.title,
542
+ url: entry.url,
543
+ ...(entry.note ? { note: entry.note } : {}),
544
+ ...(entry.avatarUrl ? { avatarUrl: entry.avatarUrl } : {}),
545
+ ...(entry.stars !== undefined ? { stars: entry.stars } : {}),
546
+ })),
547
+ ...(collection.editorial?.lastReviewedAt
548
+ ? { reviewedAt: collection.editorial.lastReviewedAt }
549
+ : {}),
550
+ isEmpty: result.isEmpty,
551
+ };
552
+ });
553
+ }
@@ -274,7 +274,8 @@ export const fullProjects: ProjectRecord[] = fullRecords.filter(
274
274
  // matches the elements the `grove-prose` CSS actually
275
275
  // styles (h1-h4, p, ul/ol/li, pre/code, blockquote, a).
276
276
  // Links are restricted to safe schemes and external links
277
- // are hardened to `rel="noopener noreferrer" target="_blank"`.
277
+ // open in a new tab with `rel="noopener"` — the referrer is kept so
278
+ // the linked project sees the directory in its analytics.
278
279
  // javascript: / data: URIs are blocked; event handlers,
279
280
  // iframes, and scripts are stripped.
280
281
  //
@@ -462,7 +463,7 @@ const ANCHOR_TRANSFORM = (tagName: string, attribs: Record<string, string>) => {
462
463
  const external = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(href);
463
464
  return {
464
465
  tagName,
465
- attribs: external ? { ...attribs, rel: 'noopener noreferrer', target: '_blank' } : attribs,
466
+ attribs: external ? { ...attribs, rel: 'noopener', target: '_blank' } : attribs,
466
467
  };
467
468
  };
468
469
 
@@ -452,6 +452,36 @@ export function getDirectoryIndexModel(
452
452
  };
453
453
  }
454
454
 
455
+ /**
456
+ * Records grouped by `submittedBy`, most submissions first. Only visible
457
+ * records count. Each person's `id` is their lowercased login — the
458
+ * anchor a record page's "Submitted by @login" links to.
459
+ */
460
+ export function getSubmissionsBySubmitter(
461
+ site: DirectorySiteConfig,
462
+ ): Array<{ id: string; login: string; items: Array<{ slug: string; name: string; url: string }> }> {
463
+ const routeSlug = site.blueprintConfig?.routeSlug ?? 'projects';
464
+ const byLogin = new Map<
465
+ string,
466
+ { id: string; login: string; items: Array<{ slug: string; name: string; url: string }> }
467
+ >();
468
+ for (const record of fullItems) {
469
+ const login = (record as { submittedBy?: string }).submittedBy;
470
+ if (!login) continue;
471
+ const id = login.toLowerCase();
472
+ const entry = byLogin.get(id) ?? { id, login, items: [] };
473
+ entry.items.push({
474
+ slug: record.slug,
475
+ name: 'name' in record && record.name ? String(record.name) : record.slug,
476
+ url: `/${routeSlug}/${record.slug}/`,
477
+ });
478
+ byLogin.set(id, entry);
479
+ }
480
+ return [...byLogin.values()].sort(
481
+ (a, b) => b.items.length - a.items.length || a.login.localeCompare(b.login),
482
+ );
483
+ }
484
+
455
485
  export function getContributorsPageModel(site: DirectorySiteConfig) {
456
486
  const contributors = loadDirectoryContributors();
457
487
  // Render-time guard: even if a stale `data/generated/contributors.json`