@cratis/cast 0.1.0 → 0.2.1

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.
Files changed (57) hide show
  1. package/README.md +3 -1
  2. package/badges/RegistryMember.ts +2 -0
  3. package/badges/badgeSvg.ts +10 -1
  4. package/badges/registry.ts +5 -0
  5. package/cast-json.schema.json +1496 -0
  6. package/config/calendar.ts +34 -0
  7. package/config/castSchema.ts +3 -2
  8. package/github/gitHubSnapshotSchema.ts +58 -0
  9. package/machine/castJson.ts +17 -4
  10. package/machine/castJsonSchema.ts +35 -0
  11. package/machine/index.ts +6 -0
  12. package/machine/profileFromCastJson.ts +215 -0
  13. package/package.json +5 -1
  14. package/routes/404.astro +6 -4
  15. package/routes/cast.json.ts +7 -1
  16. package/routes/cv.astro +3 -365
  17. package/routes/index.astro +3 -55
  18. package/site/components/Activity.astro +9 -8
  19. package/site/components/Agentic.astro +11 -10
  20. package/site/components/CareerReplay.astro +11 -8
  21. package/site/components/CommandPalette.astro +10 -4
  22. package/site/components/Contact.astro +8 -5
  23. package/site/components/Cratis.astro +18 -16
  24. package/site/components/EventModel.astro +8 -5
  25. package/site/components/Footer.astro +9 -4
  26. package/site/components/Hero.astro +13 -10
  27. package/site/components/Inline.astro +45 -0
  28. package/site/components/Monogram.astro +4 -1
  29. package/site/components/Nav.astro +12 -9
  30. package/site/components/Now.astro +13 -10
  31. package/site/components/Projects.astro +11 -14
  32. package/site/components/PullRequestFeed.astro +6 -4
  33. package/site/components/SectionHeader.astro +6 -3
  34. package/site/components/Skills.astro +5 -2
  35. package/site/components/Stats.astro +9 -4
  36. package/site/components/Talks.astro +8 -5
  37. package/site/components/Terminal.astro +7 -2
  38. package/site/components/Writing.astro +9 -7
  39. package/site/data.ts +6 -43
  40. package/site/layouts/Base.astro +31 -19
  41. package/site/lib/blog.ts +42 -16
  42. package/site/lib/github.ts +56 -31
  43. package/site/lib/inline.ts +65 -9
  44. package/site/lib/nav.ts +14 -3
  45. package/site/pages/CvPage.astro +379 -0
  46. package/site/pages/ProfilePage.astro +78 -0
  47. package/site/profile/CastHost.ts +32 -0
  48. package/site/profile/CastView.ts +96 -0
  49. package/site/profile/assertRenderable.ts +151 -0
  50. package/site/profile/clientCast.ts +120 -0
  51. package/site/profile/index.ts +8 -0
  52. package/site/scripts/live.ts +21 -11
  53. package/site/scripts/palette.ts +30 -13
  54. package/site/scripts/replay.ts +2 -1
  55. package/site/scripts/terminal.ts +40 -29
  56. package/writing/fetchWriting.ts +17 -2
  57. package/writing/writingSnapshotSchema.ts +27 -0
package/README.md CHANGED
@@ -10,4 +10,6 @@ import { defineConfig } from 'astro/config';
10
10
  export default defineConfig({ integrations: [cast()] });
11
11
  ```
12
12
 
13
- The quickest start is `npm create @cratis/cast@latest`. Documentation: [getting started](https://github.com/Cratis/Cast/blob/main/Documentation/getting-started.md), [cast.yaml reference](https://github.com/Cratis/Cast/blob/main/Documentation/cast-yaml.md), [badges and the registry](https://github.com/Cratis/Cast/blob/main/Documentation/badges-and-registry.md).
13
+ The quickest start is `npm create @cratis/cast@latest`. Documentation: [getting started](https://github.com/Cratis/Cast/blob/main/Documentation/getting-started.md), [cast.yaml reference](https://github.com/Cratis/Cast/blob/main/Documentation/cast-yaml.md), [cast.json reference](https://github.com/Cratis/Cast/blob/main/Documentation/cast-json.md), [badges and the registry](https://github.com/Cratis/Cast/blob/main/Documentation/badges-and-registry.md).
14
+
15
+ Besides the integration, the package exports what other Astro projects need to render a Cast profile: `@cratis/cast/profile` (`castView`, the hosts, the browser data), `@cratis/cast/machine` (`castJson`, `profileFromCastJson`, the cast.json schema) and the page components `@cratis/cast/site/pages/ProfilePage.astro` and `CvPage.astro`. The JSON Schemas are `@cratis/cast/cast.schema.json` (cast.yaml) and `@cratis/cast/cast-json.schema.json` (cast.json, version 2).
@@ -10,6 +10,8 @@ export type RegistryMember = {
10
10
  since?: string;
11
11
  role?: string;
12
12
  site?: string;
13
+ /** URL of the member's /cast.json, for sites that publish it elsewhere. Defaults to `<site>/cast.json`. */
14
+ profile?: string;
13
15
  company?: string;
14
16
  /** 1-based line in members.yaml where this entry starts, for "verified from" links. */
15
17
  line?: number;
@@ -94,6 +94,15 @@ export type BadgeCardOptions = {
94
94
  since?: string;
95
95
  };
96
96
 
97
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
98
+
99
+ /** `2024-06` as `Jun 2024`, matching the directory's cards; anything else is shown as given. */
100
+ const monthYear = (since: string): string => {
101
+ const match = /^(\d{4})-(\d{2})$/.exec(since);
102
+ const month = match ? months[Number(match[2]) - 1] : undefined;
103
+ return match && month ? `${month} ${match[1]}` : since;
104
+ };
105
+
97
106
  /**
98
107
  * The large badge card (480 × 168): a dark card with a tier-colored edge, the Cratis mark, the tier in
99
108
  * the italic serif and the verification address. Meant for READMEs, slides and profile pages.
@@ -106,7 +115,7 @@ export function badgeCardSvg(tier: Tier | undefined, options: BadgeCardOptions):
106
115
  const handle = options.handle.toLowerCase();
107
116
  const address = `${castDirectoryUrl.replace(/^https:\/\//, '')}/${handle}`;
108
117
  const who = options.name ? `${options.name} · @${options.handle}` : `@${options.handle}`;
109
- const sinceText = options.since ? ` · since ${options.since}` : '';
118
+ const sinceText = options.since ? ` · since ${monthYear(options.since)}` : '';
110
119
  const title = tier ? `${who}: Cratis Cast ${style.label}` : `${who}: not verified in the Cratis Cast`;
111
120
 
112
121
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${escapeXml(title)}">
@@ -12,6 +12,7 @@ export const registryMemberSchema = z.object({
12
12
  since: z.string().regex(/^\d{4}-\d{2}$/, 'Use YYYY-MM').optional(),
13
13
  role: z.string().min(1).optional(),
14
14
  site: z.url({ protocol: /^https$/ }).optional(),
15
+ profile: z.url({ protocol: /^https$/ }).optional(),
15
16
  company: z.string().min(1).optional(),
16
17
  }).strict();
17
18
 
@@ -58,6 +59,10 @@ function entryLines(document: ReturnType<typeof parseDocument>, yamlText: string
58
59
  });
59
60
  }
60
61
 
62
+ /** Where the directory reads a member's profile: `profile`, else `<site>/cast.json`, else nowhere. */
63
+ export const profileUrlOf = (member: Pick<RegistryMember, 'site' | 'profile'>): string | undefined =>
64
+ member.profile ?? (member.site ? new URL('/cast.json', member.site).toString() : undefined);
65
+
61
66
  /** Finds a member by GitHub login, case-insensitively. */
62
67
  export const findMember = (members: readonly RegistryMember[], handle: string): RegistryMember | undefined =>
63
68
  members.find(member => member.github.toLowerCase() === handle.toLowerCase());