Skip to content

Commit f02ffd7

Browse files
committed
fix small bugs and added add-on for github seo
1 parent 057e495 commit f02ffd7

File tree

3 files changed

+116
-8
lines changed

3 files changed

+116
-8
lines changed

.changeset/long-days-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-better-t-stack": minor
3+
---
4+
5+
added github seo add-on

apps/cli/src/helpers/addons-setup.ts

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ export async function setupAddons(projectDir: string, addons: ProjectAddons[]) {
1414
}
1515

1616
if (addons.includes("SEO")) {
17-
log.info(
18-
pc.yellow(
19-
"SEO feature is still a work-in-progress and will be available in a future update.",
20-
),
21-
);
17+
// log.info(
18+
// pc.yellow(
19+
// "SEO feature is still a work-in-progress and will be available in a future update.",
20+
// ),
21+
// );
22+
await setupSEO(projectDir);
2223
}
2324
}
2425

@@ -180,3 +181,105 @@ jobs:
180181
deployWorkflowContent,
181182
);
182183
}
184+
185+
async function setupSEO(projectDir: string) {
186+
const robotsContent = `# Instructions: Customize this file to control how search engines crawl your site
187+
# Learn more: https://developers.google.com/search/docs/advanced/robots/create-robots-txt
188+
189+
# Allow all crawlers (default)
190+
User-agent: *
191+
Allow: /
192+
193+
# Disallow crawling of specific directories (uncomment and customize as needed)
194+
# Disallow: /admin/
195+
# Disallow: /private/
196+
197+
# Specify the location of your sitemap
198+
Sitemap: https://yourdomain.com/sitemap.xml
199+
`;
200+
201+
await fs.writeFile(
202+
path.join(projectDir, "packages", "client", "robots.txt"),
203+
robotsContent,
204+
);
205+
206+
const sitemapContent = `<?xml version="1.0" encoding="UTF-8"?>
207+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
208+
209+
<url>
210+
<loc>https://yourdomain.com/</loc>
211+
<lastmod>2025-03-01</lastmod>
212+
<changefreq>weekly</changefreq>
213+
<priority>1.0</priority>
214+
</url>
215+
216+
<url>
217+
<loc>https://yourdomain.com/about</loc>
218+
<lastmod>2025-03-01</lastmod>
219+
<changefreq>monthly</changefreq>
220+
<priority>0.8</priority>
221+
</url>
222+
223+
</urlset>
224+
`;
225+
await fs.writeFile(
226+
path.join(projectDir, "packages", "client", "sitemap.xml"),
227+
sitemapContent,
228+
);
229+
230+
const metaContent = `<!doctype html>
231+
<html lang="en">
232+
233+
<head>
234+
<meta charset="UTF-8" />
235+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
236+
<title>TanStack Router</title>
237+
<meta name="description"
238+
content="Replace this with your page description - keep it between 150-160 characters for optimal display in search results." />
239+
<meta name="keywords" content="keyword1, keyword2, keyword3, customize based on your content" />
240+
<meta name="robots" content="index, follow" />
241+
<link rel="icon" href="/favicon.ico" />
242+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
243+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
244+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
245+
246+
<!-- OPEN GRAPH TAGS: Optimize how your content appears when shared on Facebook, LinkedIn, etc. -->
247+
<meta property="og:title" content="Replace with your page title" />
248+
<meta property="og:description"
249+
content="Replace with your page description (typically the same as meta description)" />
250+
<meta property="og:image" content="path-to-image" />
251+
<meta property="og:type" content="website" />
252+
<meta property="og:site_name" content="Your Site Name" />
253+
254+
<!-- TWITTER CARD TAGS: Optimize how your content appears when shared on Twitter -->
255+
<meta name="twitter:card" content="summary_large_image" />
256+
<meta name="twitter:title" content="Replace with your page title" />
257+
<meta name="twitter:description" content="Replace with your page description" />
258+
<meta name="twitter:image" content="path-to-image" />
259+
<meta name="twitter:creator" content="@yourtwitterhandle" />
260+
261+
<!-- STRUCTURED DATA: Help search engines understand your content better (JSON-LD format) -->
262+
<script type="application/ld+json">
263+
{
264+
"@context": "https://schema.org",
265+
"@type": "WebPage",
266+
"name": "Replace with your page title",
267+
"description": "Replace with your page description",
268+
"url": "https://yourdomain.com/your-page-url"
269+
}
270+
</script>
271+
</head>
272+
273+
<body>
274+
<div id="app"></div>
275+
<script type="module" src="/src/main.tsx"></script>
276+
</body>
277+
278+
</html>
279+
`;
280+
281+
await fs.writeFile(
282+
path.join(projectDir, "packages", "client", "index.html"),
283+
metaContent,
284+
);
285+
}

apps/cli/src/helpers/turso-setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ async function createTursoDatabase(dbName: string): Promise<TursoConfig> {
8989
async function writeEnvFile(projectDir: string, config?: TursoConfig) {
9090
const envPath = path.join(projectDir, "packages/server", ".env");
9191
const envContent = config
92-
? `TURSO_DATABASE_URL="${config.dbUrl}"
92+
? `TURSO_CONNECTION_URL="${config.dbUrl}"
9393
TURSO_AUTH_TOKEN="${config.authToken}"`
94-
: `TURSO_DATABASE_URL=
94+
: `TURSO_CONNECTION_URL=
9595
TURSO_AUTH_TOKEN=`;
9696

9797
await fs.writeFile(envPath, envContent);
@@ -105,7 +105,7 @@ function displayManualSetupInstructions() {
105105
3. Get your database URL and authentication token
106106
4. Add these credentials to the .env file in packages/server/.env
107107
108-
TURSO_DATABASE_URL=your_database_url
108+
TURSO_CONNECTION_URL=your_database_url
109109
TURSO_AUTH_TOKEN=your_auth_token`);
110110
}
111111

0 commit comments

Comments
 (0)