Skip to content

Commit

Permalink
refactor(app): Generate page.tsx from template.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 18, 2023
1 parent bd1f5f9 commit f405969
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 157 deletions.
10 changes: 6 additions & 4 deletions scripts/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const marked = new Marked(
);

(async () => {
const template = await fs.readFile("../template.html", "utf-8");
const template = await fs.readFile("../site/src/app/template.tsx", "utf-8");
let markdown = await fs.readFile("../README.md", "utf-8");
// Remove first line
markdown = markdown.substring(markdown.indexOf("\n") + 1);
Expand All @@ -29,9 +29,11 @@ const marked = new Marked(
markdown = markdown.replaceAll("- [x] ", "- ");

const html = marked.parse(markdown, { gfm: true });
const output = template.replace("<!-- content -->", html);
await fs.mkdir("../dist", { recursive: true });
await fs.writeFile("../dist/index.html", output);
const output = template.replace(
"<!-- content -->",
html.replace(/`/g, "\\`")
);
await fs.writeFile("../site/src/app/page.tsx", output);
})()
.then(() => console.log("Completed!"))
.catch((error) => {
Expand Down
3 changes: 2 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "deliverabilityguide.com-scripts",
"type": "module",
"version": "0.0.0",
"main": "index.mjs",
"main": "generate.mjs",
"scripts": {
"generate": "node generate.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion site/src/app/page.tsx → site/src/app/template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function Home() {
<Introduction />
<NavBar />
<section className="scroll-mt-14 py-16 sm:scroll-mt-32 sm:py-20 lg:py-32">
<Container dangerouslySetInnerHTML={{ __html: '<!-- content -->' }} />
<Container dangerouslySetInnerHTML={{ __html: `<!-- content -->` }} />
</section>
<Footer />
</>
Expand Down
151 changes: 0 additions & 151 deletions template.html

This file was deleted.

0 comments on commit f405969

Please sign in to comment.