Skip to content

Commit 325daa2

Browse files
Merge pull request #333 from rest-sh/codex/home-social-github-image
[codex] Use overview card for home social image
2 parents c7b1a28 + a394b6c commit 325daa2

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{{- $image := "" -}}
2-
{{- with .Params.social_image -}}
3-
{{- $image = . -}}
4-
{{- else with .File -}}
5-
{{- $stem := replaceRE "\\.md$" "" .Path -}}
6-
{{- $stem = replaceRE "/_index$" "" $stem -}}
7-
{{- if or (eq $stem "") (eq $stem "_index") -}}
8-
{{- $stem = "index" -}}
2+
{{- if .IsHome -}}
3+
{{- $image = "/images/social/github.png" -}}
4+
{{- else -}}
5+
{{- with .Params.social_image -}}
6+
{{- $image = . -}}
7+
{{- else with .File -}}
8+
{{- $stem := replaceRE "\\.md$" "" .Path -}}
9+
{{- $stem = replaceRE "/_index$" "" $stem -}}
10+
{{- if or (eq $stem "") (eq $stem "_index") -}}
11+
{{- $stem = "index" -}}
12+
{{- end -}}
13+
{{- $image = printf "/images/social/%s.png" $stem -}}
914
{{- end -}}
10-
{{- $image = printf "/images/social/%s.png" $stem -}}
1115
{{- end -}}
1216
{{- with $image -}}{{ . | absURL }}{{- end -}}

site/scripts/generate-social-images.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,15 @@ const renderSvg = ({
130130
description,
131131
section,
132132
command = "$ restish docs",
133-
descMaxLines = 3,
133+
descMaxLines,
134134
}) => {
135-
const titleLines = wrapText(title, 710, 68, 3);
136-
const descLines = wrapText(description, 690, 30, descMaxLines);
135+
const titleFontSize = title.length > 32 ? 58 : 68;
136+
const titleLineHeight = titleFontSize + 10;
137+
const titleLines = wrapText(title, 610, titleFontSize, 3);
138+
const resolvedDescMaxLines = descMaxLines ?? Math.max(3, 6 - titleLines.length);
139+
const descLines = wrapText(description, 610, 30, resolvedDescMaxLines);
137140
const titleY = 214;
138-
const descY = titleY + titleLines.length * 78 + 30;
141+
const descY = titleY + titleLines.length * titleLineHeight + 30;
139142

140143
return `<?xml version="1.0" encoding="UTF-8"?>
141144
<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
@@ -163,7 +166,7 @@ const renderSvg = ({
163166
${titleLines
164167
.map(
165168
(line, index) =>
166-
`<text x="0" y="${titleY + index * 78}" fill="#f8fafc" font-family="Space Grotesk, Arial, Helvetica, sans-serif" font-size="68" font-weight="700">${escapeXml(line)}</text>`,
169+
`<text x="0" y="${titleY + index * titleLineHeight}" fill="#f8fafc" font-family="Space Grotesk, Arial, Helvetica, sans-serif" font-size="${titleFontSize}" font-weight="700">${escapeXml(line)}</text>`,
167170
)
168171
.join("\n ")}
169172
${descLines
@@ -205,7 +208,6 @@ const renderPng = async (socialPath, svg) => {
205208
const png = new Resvg(svg, {
206209
fitTo: {mode: "width", value: width},
207210
font: {
208-
defaultFontFamily: "Space Grotesk",
209211
fontFiles: spaceGroteskFonts,
210212
loadSystemFonts: true,
211213
},
@@ -240,7 +242,7 @@ const renderGithubOverview = () =>
240242
"Explore REST-ish APIs with generic HTTP verbs, generated OpenAPI commands, shorthand input, auth, response filtering & projection, pagination, and plugins.",
241243
section: "Always Free. Always Open Source.",
242244
command: "$ brew install rest-sh/tap/restish",
243-
descMaxLines: 4,
245+
descMaxLines: 5,
244246
}),
245247
);
246248

0 commit comments

Comments
 (0)