Skip to content

Commit e637312

Browse files
committed
fix(og): clamp title length, drop unused color export, include fonts in function bundle
1 parent 3fba411 commit e637312

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

netlify.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ publish = "dist/client"
77

88
[functions]
99
directory = "netlify/functions"
10+
included_files = [
11+
"public/fonts/Inter-Regular.ttf",
12+
"public/fonts/Inter-ExtraBold.ttf",
13+
"public/images/logos/splash-dark.png",
14+
]
1015

1116
[[headers]]
1217
for = "/*"

src/server/og/colors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import type { LibraryId } from '~/libraries'
22

3-
export const OG_BASE_COLORS = {
4-
backgroundStops: ['#0c1410', '#070a0a', '#0c070f'] as const,
5-
greenAnchor: 'rgba(0, 188, 125, 0.28)',
6-
white: '#ffffff',
7-
} as const
8-
93
// Each entry matches the textStyle in `src/libraries/libraries.ts`.
104
// Values are Tailwind v4 default palette (500 shades) with an override
115
// for black/gray-100 libraries so they stay legible on the dark canvas.

src/server/og/generate.server.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { loadOgAssets } from './assets.server'
66
import { getAccentColor } from './colors'
77
import { buildOgTree } from './template'
88

9+
const MAX_TITLE_LENGTH = 80
910
const MAX_DESCRIPTION_LENGTH = 160
1011

1112
type GenerateInput = {
@@ -30,10 +31,12 @@ export async function generateOgPng(
3031
const assets = loadOgAssets()
3132
const accentColor = getAccentColor(library.id)
3233
const libraryName = library.name
33-
const docTitle = input.title?.trim() || undefined
34+
const docTitle = input.title?.trim()
35+
? clampText(input.title.trim(), MAX_TITLE_LENGTH)
36+
: undefined
3437
const rawDescription =
3538
input.description?.trim() || library.tagline || library.description || ''
36-
const description = clampDescription(rawDescription)
39+
const description = clampText(rawDescription, MAX_DESCRIPTION_LENGTH)
3740

3841
const tree = buildOgTree({
3942
libraryName,
@@ -58,7 +61,7 @@ export async function generateOgPng(
5861
return resvg.render().asPng()
5962
}
6063

61-
function clampDescription(text: string): string {
62-
if (text.length <= MAX_DESCRIPTION_LENGTH) return text
63-
return text.slice(0, MAX_DESCRIPTION_LENGTH - 1).trimEnd() + '…'
64+
function clampText(text: string, max: number): string {
65+
if (text.length <= max) return text
66+
return text.slice(0, max - 1).trimEnd() + '…'
6467
}

0 commit comments

Comments
 (0)