Skip to content

Commit a189027

Browse files
authored
feat: og image and meta description (#538)
1 parent 23ffbb1 commit a189027

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/generators/web/template.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<link rel="icon" href="https://nodejs.org/static/images/favicons/favicon.png"/>
88
<title>{{title}}</title>
9+
<meta name="description" content="Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.">
910
<link rel="stylesheet" href="styles.css" />
11+
<meta property="og:title" content="{{ogTitle}}">
12+
<meta property="og:description" content="Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.">
13+
<meta property="og:image" content="https://nodejs.org/en/next-data/og/announcement/Node.js%20%E2%80%94%20Run%20JavaScript%20Everywhere" />
14+
<meta property="og:type" content="website">
1015

1116
<link rel="preconnect" href="https://fonts.googleapis.com" />
1217
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

src/generators/web/utils/processing.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ export async function processJSXEntries(
111111
// Step 3: Create final HTML (could be parallelized in workers)
112112
const results = entries.map(({ data: { api, heading } }) => {
113113
const fileName = `${api}.js`;
114+
const title = `${heading.data.name} | ${titleSuffix}`;
114115

115116
// Replace template placeholders with actual content
116117
const renderedHtml = template
117-
.replace('{{title}}', `${heading.data.name} | ${titleSuffix}`)
118+
.replace('{{title}}', title)
118119
.replace('{{dehydrated}}', serverBundle.pages.get(fileName) ?? '')
119120
.replace('{{importMap}}', clientBundle.importMap ?? '')
120121
.replace('{{entrypoint}}', `./${fileName}?${randomUUID()}`)
121-
.replace('{{speculationRules}}', SPECULATION_RULES);
122+
.replace('{{speculationRules}}', SPECULATION_RULES)
123+
.replace('{{ogTitle}}', title);
122124

123125
// Minify HTML (input must be a Buffer)
124126
const { code: html } = minifySync(renderedHtml);

0 commit comments

Comments
 (0)