Skip to content

Commit feac7fb

Browse files
committed
chore: static og image and better og description
1 parent be2885f commit feac7fb

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/generators/web/template.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
<title>{{title}}</title>
99
<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.">
1010
<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}}" />
11+
<meta property="og:title" content="{{ogTitle}}">
12+
<meta property="og:description" content="{{ogDescription}}">
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">
1415

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

src/generators/web/utils/processing.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export async function processJSXEntries(
112112
const results = entries.map(({ data: { api, heading } }) => {
113113
const fileName = `${api}.js`;
114114
const title = `${heading.data.name} | ${titleSuffix}`;
115+
const description = `Documentation for ${heading.data.name} in Node.js v${version.version}`;
115116

116117
// Replace template placeholders with actual content
117118
const renderedHtml = template
@@ -120,7 +121,8 @@ export async function processJSXEntries(
120121
.replace('{{importMap}}', clientBundle.importMap ?? '')
121122
.replace('{{entrypoint}}', `./${fileName}?${randomUUID()}`)
122123
.replace('{{speculationRules}}', SPECULATION_RULES)
123-
.replace('{{ogTitle}}', encodeURIComponent(title));
124+
.replace('{{ogTitle}}', title)
125+
.replace('{{ogDescription}}', description);
124126

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

0 commit comments

Comments
 (0)