Skip to content

Commit be2885f

Browse files
committed
feat: og image and meta description
1 parent 776dd0b commit be2885f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/generators/web/template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
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="{{title}}">
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/{{ogTitle}}" />
1014

1115
<link rel="preconnect" href="https://fonts.googleapis.com" />
1216
<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}}', encodeURIComponent(title));
122124

123125
// Minify HTML (input must be a Buffer)
124126
const finalHTMLBuffer = HTMLMinifier.minify(Buffer.from(renderedHtml), {});

0 commit comments

Comments
 (0)