Commit 46ddaa2d30 for handsontable.com

commit 46ddaa2d307ed597e870b285a6e854674d9332bf
Author: GreenFlux <24459976+GreenFlux@users.noreply.github.com>
Date:   Wed Nov 25 05:37:34 2026 -0500

    Docs: restore the og:image social preview tag (#14451)

    * Docs: restore the og:image social preview tag

    The VuePress-to-Starlight migration dropped og:image, so every docs link
    shared on LinkedIn, Slack, or X rendered a blank preview card. Point
    og:image and twitter:image at the existing 1200x630 docs cover.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * Docs: move the social image into a module and pin it with a test

    Keeps the image URL, size, and alt text in one place, adds
    twitter:image:alt, and checks the declared size against the PNG header so
    a future change cannot drop the tags or ship a wrong size unnoticed.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
    (cherry picked from commit c97398e5e185c161fd858a55426e985e3b645c4e)

diff --git a/docs/AGENTS.md b/docs/AGENTS.md
index 2137079ccb..e098e15424 100644
--- a/docs/AGENTS.md
+++ b/docs/AGENTS.md
@@ -1246,3 +1246,13 @@ unchecked.
 `src/lib/` and `src/components/` are tooling, not content, so the docs sync does not port this to `prod-docs/*`: it reaches the live site at the next prod-docs cut or through a hand cherry-pick.

 Unit tests: `src/lib/__tests__/headway-bell.test.mjs` (`npm run docs:test:plugins`), against a fake that defers callbacks the way the widget does. The real widget: `tests/headwayBell.spec.ts` (the `functional` project, run by the `functional` job in `.github/workflows/docs.yml` on a hosted runner against the PR preview). It skips when Headway is unreachable, which the job summary's skipped count shows, and the job runs only after the earlier gates are green.
+
+## 2.26 The social preview image is set in one module
+
+Starlight emits `og:title`, `og:description`, and `twitter:card=summary_large_image`, but no image, so link previews on LinkedIn, Slack, and X show a blank card unless the site adds one. The VuePress-to-Starlight migration (#12195) dropped it with no failing check. `src/lib/social-image.mjs` now owns it: `SOCIAL_IMAGE` names the file in `public/` (`handsontable-docs-cover.png`), its absolute URL, its size, and its alt text, and `socialImageHead()` returns the `og:image*` and `twitter:image*` entries that `astro.config.mjs` spreads into the Starlight `head`.
+
+- **The URL is absolute,** because crawlers don't resolve a relative `og:image`. So a pull request preview serves the production copy of the file: a new or resized image shows only after the production deploy.
+- **The size is declared by hand and checked.** `src/lib/__tests__/social-image.test.mjs` (`npm run docs:test:plugins`) reads the PNG header and fails when `width` or `height` does not match the file, and it fails when the config stops spreading `socialImageHead()`. Replace the image with another 1200x630 PNG, or update both numbers.
+- **Every page gets the same image.** A page-specific image needs a frontmatter `head` entry, which Starlight merges over the config's.
+
+This is tooling, not content, so the docs sync does not port it to `prod-docs/*`: it reaches the live site at the next prod-docs cut or through a hand cherry-pick.
diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs
index 80f3550b33..ed7289f6e5 100644
--- a/docs/astro.config.mjs
+++ b/docs/astro.config.mjs
@@ -24,6 +24,7 @@ import { buildAllSidebars, buildAllValidUrls, FRAMEWORK_PREFIXES } from './src/s
 import { AGENT_NOTE_MD } from './src/agent-note.mjs';
 import { buildLlmsFull, buildLlmsIndex, buildLlmsSections, SITE_URL } from './src/llms.mjs';
 import { resolveHotVersion } from './src/lib/hot-version.mjs';
+import { socialImageHead } from './src/lib/social-image.mjs';
 import { resolveSentryRelease } from './src/lib/sentry-release.mjs';
 import { buildVersionList, createCommonJsonHooks, toMinor } from './src/lib/docs-versions.mjs';
 import { resolve, dirname } from 'path';
@@ -754,6 +755,8 @@ export default defineConfig({
             'utf8'
           ),
         },
+        // Social preview image for link previews (LinkedIn, Slack, X).
+        ...socialImageHead(),
         {
           tag: 'script',
           attrs: { src: '/docs/example-tabs.js', defer: true },
diff --git a/docs/src/lib/__tests__/social-image.test.mjs b/docs/src/lib/__tests__/social-image.test.mjs
new file mode 100644
index 0000000000..168172c53c
--- /dev/null
+++ b/docs/src/lib/__tests__/social-image.test.mjs
@@ -0,0 +1,47 @@
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import { dirname, resolve } from 'node:path';
+import test from 'node:test';
+import { fileURLToPath } from 'node:url';
+import { SOCIAL_IMAGE, socialImageHead } from '../social-image.mjs';
+
+const here = dirname(fileURLToPath(import.meta.url));
+const docsRoot = resolve(here, '../../..');
+
+/**
+ * Returns the meta entries keyed by their `property` or `name`.
+ *
+ * @returns {Map<string, string>}
+ */
+function metaByKey() {
+  return new Map(socialImageHead().map(({ attrs }) => [attrs.property ?? attrs.name, attrs.content]));
+}
+
+test('the head entries name the image with an absolute URL for Open Graph and X', () => {
+  const meta = metaByKey();
+
+  assert.equal(meta.get('og:image'), 'https://handsontable.com/docs/handsontable-docs-cover.png');
+  assert.equal(meta.get('twitter:image'), meta.get('og:image'));
+  assert.equal(meta.get('og:image:width'), String(SOCIAL_IMAGE.width));
+  assert.equal(meta.get('og:image:height'), String(SOCIAL_IMAGE.height));
+  assert.ok(meta.get('og:image:alt'));
+  assert.equal(meta.get('twitter:image:alt'), meta.get('og:image:alt'));
+  assert.ok(SOCIAL_IMAGE.url.endsWith(`/docs/${SOCIAL_IMAGE.file}`));
+});
+
+test('the declared size matches the PNG in docs/public', () => {
+  const png = readFileSync(resolve(docsRoot, 'public', SOCIAL_IMAGE.file));
+
+  // PNG signature, then the IHDR chunk: width and height are big-endian at bytes 16 and 20.
+  assert.equal(png.subarray(1, 4).toString('latin1'), 'PNG');
+  assert.equal(png.subarray(12, 16).toString('latin1'), 'IHDR');
+  assert.equal(png.readUInt32BE(16), SOCIAL_IMAGE.width);
+  assert.equal(png.readUInt32BE(20), SOCIAL_IMAGE.height);
+});
+
+test('the docs config puts the social image entries in the Starlight head', () => {
+  const config = readFileSync(resolve(docsRoot, 'astro.config.mjs'), 'utf8');
+
+  assert.match(config, /^import \{ socialImageHead \} from '\.\/src\/lib\/social-image\.mjs';$/m);
+  assert.match(config, /^\s*\.\.\.socialImageHead\(\),$/m);
+});
diff --git a/docs/src/lib/social-image.mjs b/docs/src/lib/social-image.mjs
new file mode 100644
index 0000000000..74b2f64f9e
--- /dev/null
+++ b/docs/src/lib/social-image.mjs
@@ -0,0 +1,38 @@
+import { SITE_URL } from '../agent-note.mjs';
+
+/**
+ * The image that link previews (LinkedIn, Slack, X) show for every docs page.
+ * The file lives in `docs/public/`, and `width` and `height` must match it:
+ * `__tests__/social-image.test.mjs` reads the PNG header to check.
+ *
+ * The URL is absolute because crawlers don't resolve a relative `og:image`.
+ * So a pull request preview serves the production copy of the file, and a
+ * changed image shows only after the production deploy.
+ */
+export const SOCIAL_IMAGE = {
+  file: 'handsontable-docs-cover.png',
+  url: `${SITE_URL}/docs/handsontable-docs-cover.png`,
+  width: 1200,
+  height: 630,
+  alt: 'Handsontable Documentation',
+};
+
+/**
+ * Returns the Starlight `head` entries for the social preview image.
+ * Starlight emits `og:title`, `og:description`, and
+ * `twitter:card=summary_large_image` by itself, but no image.
+ *
+ * @returns {Array<{ tag: 'meta', attrs: Record<string, string> }>}
+ */
+export function socialImageHead() {
+  const { url, width, height, alt } = SOCIAL_IMAGE;
+
+  return [
+    { tag: 'meta', attrs: { property: 'og:image', content: url } },
+    { tag: 'meta', attrs: { property: 'og:image:width', content: String(width) } },
+    { tag: 'meta', attrs: { property: 'og:image:height', content: String(height) } },
+    { tag: 'meta', attrs: { property: 'og:image:alt', content: alt } },
+    { tag: 'meta', attrs: { name: 'twitter:image', content: url } },
+    { tag: 'meta', attrs: { name: 'twitter:image:alt', content: alt } },
+  ];
+}