@luciodale/docs-ui-kit 0.3.1 → 0.3.2

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 CHANGED
@@ -621,6 +621,31 @@ export const prerender = true;
621
621
 
622
622
  React islands require `@astrojs/react` in your Astro project. The docs-ui-kit itself has zero React dependency.
623
623
 
624
+ ## OG Image Generator
625
+
626
+ Generate a 1200x630 Open Graph preview image for link sharing (Slack, Twitter, Discord, etc.). Reads `public/logo.svg` for the logo and `installCommand` from `src/config.ts` for the npm package name. Outputs `public/og-image.png`.
627
+
628
+ ```bash
629
+ bun run og-image <path-to-docs-site>
630
+ ```
631
+
632
+ Example from the docs-ui-kit root:
633
+
634
+ ```bash
635
+ bun run og-image ../react-socket/packages/docs
636
+ ```
637
+
638
+ Then set `ogImage` in the docs site config:
639
+
640
+ ```ts
641
+ export const siteConfig: SiteConfig = {
642
+ // ...
643
+ ogImage: "/og-image.png",
644
+ };
645
+ ```
646
+
647
+ The SEO component picks up `ogImage` and renders `og:image`, `og:image:width`, `og:image:height`, and `twitter:image` tags automatically.
648
+
624
649
  ## Color palette
625
650
 
626
651
  Defined in `theme.css` via Tailwind v4 `@theme` tokens:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luciodale/docs-ui-kit",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Astro component library for documentation sites. Dark theme, orange accent.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,8 @@
19
19
  "lint:fix": "biome check --write .",
20
20
  "build": "bunx @tailwindcss/cli --input src/styles/build-input.css --output src/styles/utilities.css --minify",
21
21
  "npm": "bun run build && npm publish --access public",
22
- "npm:test": "npm pack --dry-run"
22
+ "npm:test": "npm pack --dry-run",
23
+ "og-image": "bun run scripts/generate-og-image.ts"
23
24
  },
24
25
  "peerDependencies": {
25
26
  "astro": ">=5"
@@ -29,6 +30,7 @@
29
30
  },
30
31
  "devDependencies": {
31
32
  "@biomejs/biome": "^2.4.7",
33
+ "@resvg/resvg-js": "^2.6.2",
32
34
  "@tailwindcss/cli": "^4.2.2",
33
35
  "astro": "^5.0.0",
34
36
  "tailwindcss": "^4.2.2",
@@ -23,8 +23,9 @@ const {
23
23
  noindex = false,
24
24
  } = Astro.props;
25
25
 
26
- const canonicalUrl = new URL(currentPath, config.siteUrl).href;
27
- const ogImageUrl = config.ogImage ? new URL(config.ogImage, config.siteUrl).href : undefined;
26
+ const baseUrl = config.siteUrl.endsWith("/") ? config.siteUrl : `${config.siteUrl}/`;
27
+ const canonicalUrl = new URL(currentPath.replace(/^\//, ""), baseUrl).href;
28
+ const ogImageUrl = config.ogImage ? new URL(config.ogImage.replace(/^\//, ""), baseUrl).href : undefined;
28
29
  const fullTitle = currentPath === "/" ? title : `${title} | ${config.title}`;
29
30
 
30
31
  const jsonLd =
@@ -66,7 +67,7 @@ const breadcrumbs = currentPath === "/" ? null : {
66
67
  "@type": "ListItem",
67
68
  position: i + 1,
68
69
  name: segment.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()),
69
- item: new URL(arr.slice(0, i + 1).join("/"), config.siteUrl).href,
70
+ item: new URL(arr.slice(0, i + 1).join("/"), baseUrl).href,
70
71
  })),
71
72
  };
72
73
 
@@ -145,7 +145,8 @@
145
145
  async function loadPagefind(): Promise<PagefindAPI | null> {
146
146
  if (pagefind) return pagefind;
147
147
  try {
148
- const path = "/_pagefind/pagefind.js";
148
+ const base = import.meta.env.BASE_URL.replace(/\/$/, "");
149
+ const path = `${base}/_pagefind/pagefind.js`;
149
150
  pagefind = await import(/* @vite-ignore */ path) as PagefindAPI;
150
151
  await pagefind.init();
151
152
  return pagefind;