Skip to content

Commit 6372ce1

Browse files
authored
Merge pull request #6 from pythonicode/feat/og-image-minimal
Add minimal social preview image and Open Graph tags
2 parents c25457e + dfa2204 commit 6372ce1

4 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎index.html‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
88
<meta name="theme-color" content="#f97316" />
99
<meta name="description" content="Analyze orienteering maps — import GPX tracks, draw routes, and export annotated maps." />
10+
<link rel="canonical" href="https://oanalysis.com/" />
11+
<meta property="og:type" content="website" />
12+
<meta property="og:site_name" content="O-Analysis" />
13+
<meta property="og:title" content="O-Analysis — orienteering map analysis" />
14+
<meta property="og:description" content="Analyze orienteering maps — import GPX tracks, draw routes, and export annotated maps." />
15+
<meta property="og:url" content="https://oanalysis.com/" />
16+
<meta property="og:image" content="https://oanalysis.com/og-image.png" />
17+
<meta property="og:image:width" content="1200" />
18+
<meta property="og:image:height" content="630" />
19+
<meta property="og:image:alt" content="A map with GPX tracks and numbered control markers, shown in O-Analysis" />
20+
<meta name="twitter:card" content="summary_large_image" />
21+
<meta name="twitter:title" content="O-Analysis — orienteering map analysis" />
22+
<meta name="twitter:description" content="Analyze orienteering maps — import GPX tracks, draw routes, and export annotated maps." />
23+
<meta name="twitter:image" content="https://oanalysis.com/og-image.png" />
1024
<meta name="application-name" content="O-Analysis" />
1125
<meta name="apple-mobile-web-app-capable" content="yes" />
1226
<meta name="apple-mobile-web-app-title" content="O-Analysis" />

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"generate-icons": "node scripts/generate-pwa-icons.mjs",
9+
"generate-og-image": "bun run scripts/generate-og-image.mjs",
910
"build": "bun run generate-icons && tsc -b && vite build",
1011
"lint": "oxlint",
1112
"test": "vitest run",

‎public/og-image.png‎

40.2 KB
Loading

‎scripts/generate-og-image.mjs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { readFileSync, writeFileSync } from 'node:fs'
2+
import { dirname, join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
import sharp from 'sharp'
5+
6+
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
7+
const WIDTH = 1200
8+
const HEIGHT = 630
9+
10+
const BACKGROUND = '#111111'
11+
const TITLE = '#fafafa'
12+
const TAGLINE = '#a3a3a3'
13+
const FONT = 'Helvetica, Arial, sans-serif'
14+
15+
const logo = readFileSync(join(root, 'public/favicon.svg')).toString('base64')
16+
17+
// Everything is centred on a single solid background
18+
const svg = `
19+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${WIDTH}" height="${HEIGHT}" viewBox="0 0 ${WIDTH} ${HEIGHT}">
20+
<rect width="${WIDTH}" height="${HEIGHT}" fill="${BACKGROUND}"/>
21+
22+
<image href="data:image/svg+xml;base64,${logo}" x="${WIDTH / 2 - 56}" y="153" width="112" height="112"/>
23+
24+
<text x="${WIDTH / 2}" y="351" text-anchor="middle" font-family="${FONT}" font-size="92" font-weight="700" fill="${TITLE}" letter-spacing="-2">O-Analysis</text>
25+
26+
<text text-anchor="middle" font-family="${FONT}" font-size="34" fill="${TAGLINE}">
27+
<tspan x="${WIDTH / 2}" y="429">Analyze and annotate your</tspan>
28+
<tspan x="${WIDTH / 2}" y="473">orienteering sessions</tspan>
29+
</text>
30+
</svg>`
31+
32+
const png = await sharp(Buffer.from(svg)).png().toBuffer()
33+
writeFileSync(join(root, 'public/og-image.png'), png)
34+
console.log(`Generated og-image.png (${WIDTH}x${HEIGHT})`)

0 commit comments

Comments
 (0)