Skip to content

Commit e65c9c4

Browse files
committed
docs: enhance examples tables
1 parent 928ec38 commit e65c9c4

File tree

27 files changed

+139
-195
lines changed

27 files changed

+139
-195
lines changed

docs/site/components/examples-table.tsx

+69-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,63 @@
1-
import { EXAMPLES } from "@/example-data/examples";
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
import { z } from "zod";
4+
5+
const ExampleMetaSchema = z
6+
.object({
7+
slug: z.string(),
8+
name: z.string(),
9+
description: z.string(),
10+
template: z.string().optional(),
11+
maintainedByCoreTeam: z.boolean(),
12+
})
13+
.strict();
14+
15+
type ExampleMeta = z.infer<typeof ExampleMetaSchema>;
16+
17+
// Collect metadata from each example
18+
const EXAMPLES: ExampleMeta[] = [];
19+
20+
// Get all directories in the examples folder
21+
const examplesDir = path.join(process.cwd() + "../../../examples");
22+
const examples = fs
23+
.readdirSync(examplesDir, { withFileTypes: true })
24+
.filter(
25+
(dirent) =>
26+
dirent.isDirectory() &&
27+
!dirent.name.startsWith(".") &&
28+
dirent.name !== "node_modules"
29+
)
30+
.filter((dirent) => dirent.name !== "with-nextjs")
31+
// @ts-expect-error
32+
.sort((a, b) => a.name - b.name)
33+
.map((dirent) => dirent.name);
34+
35+
for (const example of examples) {
36+
const metaPath = path.join(examplesDir, example, "meta.json");
37+
38+
// Check if meta.json exists
39+
if (fs.existsSync(metaPath)) {
40+
try {
41+
const metaContent = fs.readFileSync(metaPath, "utf8");
42+
const metaJson = JSON.parse(metaContent);
43+
EXAMPLES.push({ ...metaJson, slug: example });
44+
} catch (error) {
45+
// @ts-expect-error
46+
throw new Error(error);
47+
}
48+
}
49+
}
50+
51+
// Validate examples against schema
52+
const validatedExamples = z.array(ExampleMetaSchema).parse(EXAMPLES);
253

354
export function ExamplesTable({
455
coreMaintained,
556
}: {
657
coreMaintained?: boolean;
758
}): JSX.Element {
859
return (
9-
<div className="max-w-full overflow-auto">
60+
<div className="overflow-auto max-w-full">
1061
<table>
1162
<thead>
1263
<tr>
@@ -19,20 +70,22 @@ export function ExamplesTable({
1970
coreMaintained
2071
? meta.maintainedByCoreTeam
2172
: !meta.maintainedByCoreTeam
22-
).map((example) => (
23-
<tr key={example.slug}>
24-
<td>
25-
<a
26-
href={`https://github.com/vercel/turborepo/tree/main/examples/${example.slug}`}
27-
rel="noopener noreferrer"
28-
target="_blank"
29-
>
30-
{example.slug}
31-
</a>
32-
</td>
33-
<td className="sm:text-wrap">{example.description}</td>
34-
</tr>
35-
))}
73+
).map((example) => {
74+
return (
75+
<tr key={example.slug}>
76+
<td>
77+
<a
78+
href={`https://github.com/vercel/turborepo/tree/main/examples/${example.slug}`}
79+
rel="noopener noreferrer"
80+
target="_blank"
81+
>
82+
{example.name}
83+
</a>
84+
</td>
85+
<td className="sm:text-wrap">{example.description}</td>
86+
</tr>
87+
);
88+
})}
3689
</tbody>
3790
</table>
3891
</div>

docs/site/content/repo-docs/getting-started/examples.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pnpm dlx create-turbo@latest --example [github-url]
4949

5050
## Core-maintained examples
5151

52-
This list is maintained by the Turborepo core team. Dependencies are kept as up-to-date as possible and GitHub Issues are accepted and addressed for these examples.
52+
This following examples are maintained by the Turborepo core team. Dependencies are kept as up-to-date as possible and GitHub Issues are accepted and addressed for these examples.
5353

5454
<ExamplesTable coreMaintained />
5555

docs/site/example-data/examples.ts

-150
This file was deleted.

examples/basic/meta.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2+
"name": "Basic",
3+
"description": "Basic monorepo example with two Next.js applications",
24
"maintainedByCoreTeam": true
35
}

examples/design-system/meta.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Design System",
3-
"description": "Unify your site's look and feel by sharing a design system across multiple apps.",
3+
"description": "Unify your site's look and feel by sharing a design system across multiple apps",
44
"template": "https://vercel.com/templates/react/turborepo-design-system",
5-
"featured": true
5+
"maintainedByCoreTeam": false
66
}

examples/kitchen-sink/meta.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"name": "Kitchen Sink",
3-
"description": "Want to see a more in-depth example? Includes multiple frameworks, both frontend and backend.",
2+
"name": "Kitchen sink",
3+
"description": "Multiple frameworks, both frontend and backend",
44
"template": "https://vercel.com/templates/remix/turborepo-kitchensink",
5-
"featured": true,
65
"maintainedByCoreTeam": true
76
}

examples/with-angular/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "Angular",
3-
"description": "Minimal Turborepo example for learning the fundamentals."
3+
"description": "Minimal Turborepo example for learning the fundamentals",
4+
"maintainedByCoreTeam": false
45
}

examples/with-berry/meta.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Yarn Berry",
3+
"description": "Monorepo example using Yarn Berry (Yarn 3)",
4+
"maintainedByCoreTeam": false
5+
}

examples/with-changesets/meta.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"name": "Monorepo with Changesets",
3-
"description": "Simple Next.js monorepo preconfigured to publish packages via Changesets"
2+
"name": "Changesets",
3+
"description": "Configured to publish packages via Changesets",
4+
"maintainedByCoreTeam": false
45
}

examples/with-docker/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "Docker",
3-
"description": "Monorepo with an Express API and a Next.js App deployed with Docker utilizing turbo prune"
3+
"description": "Monorepo with an Express API and a Next.js App deployed with Docker utilizing turbo prune",
4+
"maintainedByCoreTeam": false
45
}

examples/with-gatsby/meta.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "Gatsby.js",
2+
"name": "Gatsby",
33
"description": "Monorepo with a Gatsby.js and a Next.js app both sharing a UI Library",
44
"template": "https://vercel.com/templates/gatsby/turborepo-gatsby-starter",
5-
"featured": true
5+
"maintainedByCoreTeam": false
66
}

examples/with-nestjs/meta.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"name": "Next.js",
3-
"description": "Minimal Turborepo example for learning the fundamentals.",
4-
"template": "https://vercel.com/templates/next.js/turborepo-next-basic",
5-
"featured": true,
6-
"boost": true
2+
"name": "Nest.js",
3+
"description": "Monorepo with Nest.js",
4+
"maintainedByCoreTeam": false
75
}

examples/with-nextjs/meta.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Next.js",
3+
"description": "Monorepo example with Next.js applications",
4+
"maintainedByCoreTeam": false
5+
}

examples/with-npm/meta.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "npm workspaces",
3+
"description": "Monorepo example using NPM workspaces",
4+
"maintainedByCoreTeam": false
5+
}

examples/with-prisma/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "Prisma",
3-
"description": "Monorepo with a Next.js App fully configured with Prisma"
3+
"description": "Monorepo with a Next.js App fully configured with Prisma",
4+
"maintainedByCoreTeam": false
45
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "React Native",
33
"description": "Simple React Native & Next.js monorepo with a shared UI library",
4-
"featured": true,
5-
"template": "https://vercel.com/templates/react/turborepo-design-system"
4+
"template": "https://vercel.com/templates/react/turborepo-design-system",
5+
"maintainedByCoreTeam": false
66
}

examples/with-rollup/meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "Rollup",
3-
"description": "Monorepo with a single Next.js app sharing a UI library bundled with Rollup"
3+
"description": "Monorepo with a single Next.js app sharing a UI library bundled with Rollup",
4+
"maintainedByCoreTeam": false
45
}
+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2+
"name": "Shell commands",
3+
"description": "A nearly empty Turborepo - useful for creating reproductions for GitHub Issues",
24
"maintainedByCoreTeam": true
35
}

examples/with-solid/meta.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Solid.js",
3+
"description": "Monorepo example with SolidJS applications",
4+
"maintainedByCoreTeam": false
5+
}

examples/with-svelte/meta.json

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"name": "SvelteKit",
33
"description": "Monorepo with multiple SvelteKit apps sharing a UI Library",
4-
"featured": true,
54
"template": "https://vercel.com/templates/svelte/turborepo-sveltekit-starter",
6-
"boost": true,
75
"maintainedByCoreTeam": true
86
}

0 commit comments

Comments
 (0)