Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/generators/web/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="https://nodejs.org/static/images/favicons/favicon.png"/>
<title>{{title}}</title>
Comment thread
canerakdas marked this conversation as resolved.
<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.">
Comment thread
canerakdas marked this conversation as resolved.
<link rel="stylesheet" href="styles.css" />
<meta property="og:title" content="{{title}}">
Comment thread
canerakdas marked this conversation as resolved.
Outdated
<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.">
<meta property="og:image" content="https://nodejs.org/en/next-data/og/announcement/{{ogTitle}}" />
Comment thread
canerakdas marked this conversation as resolved.
Outdated
Comment thread
canerakdas marked this conversation as resolved.
Outdated

Comment thread
canerakdas marked this conversation as resolved.
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
Expand Down
6 changes: 4 additions & 2 deletions src/generators/web/utils/processing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,16 @@ export async function processJSXEntries(
// Step 3: Create final HTML (could be parallelized in workers)
const results = entries.map(({ data: { api, heading } }) => {
const fileName = `${api}.js`;
const title = `${heading.data.name} | ${titleSuffix}`;

// Replace template placeholders with actual content
const renderedHtml = template
.replace('{{title}}', `${heading.data.name} | ${titleSuffix}`)
.replace('{{title}}', title)
.replace('{{dehydrated}}', serverBundle.pages.get(fileName) ?? '')
.replace('{{importMap}}', clientBundle.importMap ?? '')
.replace('{{entrypoint}}', `./${fileName}?${randomUUID()}`)
.replace('{{speculationRules}}', SPECULATION_RULES);
.replace('{{speculationRules}}', SPECULATION_RULES)
.replace('{{ogTitle}}', encodeURIComponent(title));

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