-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple entry points with configurable HTML tags (#398)
- Loading branch information
Showing
11 changed files
with
317 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const currentPath = fileURLToPath(import.meta.url); | ||
const projectRoot = path.dirname(currentPath); | ||
const templateFilePath = path.resolve(projectRoot, '../template.html'); | ||
const entryPointsDir = path.resolve(projectRoot, '../entry-points'); | ||
|
||
const ENTRY_POINTS = [ | ||
{ | ||
title: 'dYdX', | ||
description: 'dYdX', | ||
fileName: 'index.html', | ||
}, | ||
]; | ||
|
||
try { | ||
fs.mkdir(entryPointsDir, { recursive: true }); | ||
|
||
for (const entryPoint of ENTRY_POINTS) { | ||
const html = await fs.readFile(templateFilePath, 'utf-8'); | ||
const destinationFilePath = path.resolve(entryPointsDir, entryPoint.fileName); | ||
const injectedHtml = html.replace( | ||
'<title>dYdX</title>', | ||
`<title>${entryPoint.title}</title>\n <meta name="description" content="${entryPoint.description}" />` | ||
); | ||
await fs.writeFile(destinationFilePath, injectedHtml, 'utf-8'); | ||
} | ||
} catch (err) { | ||
console.error('Error generating entry points:', err); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.