mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Add Todo button to homepage when examples are included
Add project creation time display in success message
This commit is contained in:
@@ -48,6 +48,7 @@ async function setupTodoExample(
|
||||
}
|
||||
|
||||
await updateHeaderWithTodoLink(projectDir, auth);
|
||||
await addTodoButtonToHomepage(projectDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,3 +129,28 @@ async function updateRouterIndex(projectDir: string): Promise<void> {
|
||||
await fs.writeFile(routerFile, routerContent);
|
||||
}
|
||||
}
|
||||
|
||||
async function addTodoButtonToHomepage(projectDir: string): Promise<void> {
|
||||
const indexPath = path.join(
|
||||
projectDir,
|
||||
"packages/client/src/routes/index.tsx",
|
||||
);
|
||||
|
||||
if (await fs.pathExists(indexPath)) {
|
||||
let indexContent = await fs.readFile(indexPath, "utf8");
|
||||
|
||||
indexContent = indexContent.replace(
|
||||
/<div id="buttons"><\/div>/,
|
||||
`<div id="buttons" className="mt-4 flex flex-col gap-4 sm:flex-row sm:items-center">
|
||||
<Button asChild>
|
||||
<Link to="/todos" className="flex items-center">
|
||||
View Todo Demo
|
||||
<ArrowRight className="ml-1 h-4 w-4" />
|
||||
</Link>
|
||||
</Button>
|
||||
</div>`,
|
||||
);
|
||||
|
||||
await fs.writeFile(indexPath, indexContent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user