Skip to content

Commit 7ba2ac0

Browse files
committed
Merge branch 'fix/og-image-public'
2 parents e10ba63 + 414dc0b commit 7ba2ac0

7 files changed

Lines changed: 60 additions & 3 deletions

File tree

website/llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ make install # Installs binary + shell completions + man pages
4040

4141
```bash
4242
sql-splitter --version
43-
# sql-splitter 1.14.0
43+
# sql-splitter 1.14.1
4444
```
4545

4646
## Commands Overview

website/og-image.png

-55.9 KB
Binary file not shown.

website/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"build": "astro build",
1111
"preview": "astro preview",
1212
"astro": "astro",
13+
"og": "tsx scripts/generate-og-image.ts",
1314
"test": "playwright test",
1415
"format": "bunx prettier . --write",
1516
"test:ui": "playwright test --ui",
@@ -23,7 +24,7 @@
2324
"@resvg/resvg-js": "^2.6.2",
2425
"@types/react": "^18.3.31",
2526
"@types/react-dom": "^18.3.7",
26-
"astro": "^7.0.7",
27+
"astro": "^7.0.9",
2728
"astro-indexnow": "^2.3.10",
2829
"react": "^18.3.1",
2930
"react-dom": "^18.3.1",
@@ -38,6 +39,6 @@
3839
"ajv-cli": "^5.0.0",
3940
"ajv-formats": "^3.0.1",
4041
"tailwindcss": "^4.3.2",
41-
"tsx": "^4.23.0"
42+
"tsx": "^4.23.1"
4243
}
4344
}

website/public/og-image.png

59.9 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Renders og-image.html to public/og-image.png (1200x630).
4+
*
5+
* The homepage BaseLayout references a static image at /og-image.png, which
6+
* Astro serves from public/. Generating straight into public/ keeps the
7+
* committed image and its HTML source from drifting apart.
8+
*
9+
* Usage: bun run og (or: npx tsx scripts/generate-og-image.ts)
10+
*/
11+
12+
import { resolve, dirname } from "node:path";
13+
import { fileURLToPath, pathToFileURL } from "node:url";
14+
import { chromium } from "playwright";
15+
16+
const __dirname = dirname(fileURLToPath(import.meta.url));
17+
const source = resolve(__dirname, "../og-image.html");
18+
const output = resolve(__dirname, "../public/og-image.png");
19+
20+
const browser = await chromium.launch();
21+
const page = await browser.newPage({
22+
viewport: { width: 1200, height: 630 },
23+
deviceScaleFactor: 1,
24+
});
25+
await page.goto(pathToFileURL(source).href);
26+
// Wait for the webfont to load so text renders with the intended face.
27+
await page.evaluate(() => document.fonts.ready);
28+
await page.screenshot({
29+
path: output,
30+
clip: { x: 0, y: 0, width: 1200, height: 630 },
31+
});
32+
await browser.close();
33+
34+
console.log(`Rendered ${output}`);

website/src/layouts/BaseLayout.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const { title, description = 'High-performance SQL dump toolkit. Split, merge, c
2323
<meta property="og:image" content="https://sql-splitter.dev/og-image.png">
2424
<meta property="og:image:width" content="1200">
2525
<meta property="og:image:height" content="630">
26+
<meta property="og:image:type" content="image/png">
2627

2728
<!-- Twitter Card -->
2829
<meta name="twitter:card" content="summary_large_image">

website/src/routeData.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ export const onRequest = defineRouteMiddleware((context, next) => {
2323
content: ogImageUrl,
2424
},
2525
},
26+
{
27+
tag: "meta",
28+
attrs: {
29+
property: "og:image:width",
30+
content: "1200",
31+
},
32+
},
33+
{
34+
tag: "meta",
35+
attrs: {
36+
property: "og:image:height",
37+
content: "630",
38+
},
39+
},
40+
{
41+
tag: "meta",
42+
attrs: {
43+
property: "og:image:type",
44+
content: "image/png",
45+
},
46+
},
2647
{
2748
tag: "meta",
2849
attrs: {

0 commit comments

Comments
 (0)