这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 69 additions & 16 deletions docs/site/components/examples-table.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,63 @@
import { EXAMPLES } from "@/example-data/examples";
import fs from "node:fs";
import path from "node:path";
import { z } from "zod";

const ExampleMetaSchema = z
.object({
slug: z.string(),
name: z.string(),
description: z.string(),
template: z.string().optional(),
maintainedByCoreTeam: z.boolean(),
})
.strict();

type ExampleMeta = z.infer<typeof ExampleMetaSchema>;

// Collect metadata from each example
const EXAMPLES: ExampleMeta[] = [];

// Get all directories in the examples folder
const examplesDir = path.join(process.cwd() + "../../../examples");
const examples = fs
.readdirSync(examplesDir, { withFileTypes: true })
.filter(
(dirent) =>
dirent.isDirectory() &&
!dirent.name.startsWith(".") &&
dirent.name !== "node_modules"
)
.filter((dirent) => dirent.name !== "with-nextjs")
// @ts-expect-error
.sort((a, b) => a.name - b.name)
.map((dirent) => dirent.name);

for (const example of examples) {
const metaPath = path.join(examplesDir, example, "meta.json");

// Check if meta.json exists
if (fs.existsSync(metaPath)) {
try {
const metaContent = fs.readFileSync(metaPath, "utf8");
const metaJson = JSON.parse(metaContent);
EXAMPLES.push({ ...metaJson, slug: example });
} catch (error) {
// @ts-expect-error
throw new Error(error);
}
}
}

// Validate examples against schema
z.array(ExampleMetaSchema).parse(EXAMPLES);

export function ExamplesTable({
coreMaintained,
}: {
coreMaintained?: boolean;
}): JSX.Element {
return (
<div className="max-w-full overflow-auto">
<div className="overflow-auto max-w-full">
<table>
<thead>
<tr>
Expand All @@ -19,20 +70,22 @@ export function ExamplesTable({
coreMaintained
? meta.maintainedByCoreTeam
: !meta.maintainedByCoreTeam
).map((example) => (
<tr key={example.slug}>
<td>
<a
href={`https://github.com/vercel/turborepo/tree/main/examples/${example.slug}`}
rel="noopener noreferrer"
target="_blank"
>
{example.slug}
</a>
</td>
<td className="sm:text-wrap">{example.description}</td>
</tr>
))}
).map((example) => {
return (
<tr key={example.slug}>
<td>
<a
href={`https://github.com/vercel/turborepo/tree/main/examples/${example.slug}`}
rel="noopener noreferrer"
target="_blank"
>
{example.name}
</a>
</td>
<td className="sm:text-wrap">{example.description}</td>
</tr>
);
})}
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/site/content/repo-docs/getting-started/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pnpm dlx create-turbo@latest --example [github-url]

## Core-maintained examples

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.
The 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.

<ExamplesTable coreMaintained />

Expand Down
150 changes: 0 additions & 150 deletions docs/site/example-data/examples.ts

This file was deleted.

2 changes: 2 additions & 0 deletions examples/basic/meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"name": "Basic",
"description": "Basic monorepo example with two Next.js applications",
"maintainedByCoreTeam": true
}
4 changes: 2 additions & 2 deletions examples/design-system/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Design System",
"description": "Unify your site's look and feel by sharing a design system across multiple apps.",
"description": "Unify your site's look and feel by sharing a design system across multiple apps",
"template": "https://vercel.com/templates/react/turborepo-design-system",
"featured": true
"maintainedByCoreTeam": false
}
5 changes: 2 additions & 3 deletions examples/kitchen-sink/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "Kitchen Sink",
"description": "Want to see a more in-depth example? Includes multiple frameworks, both frontend and backend.",
"name": "Kitchen sink",
"description": "Multiple frameworks, both frontend and backend",
"template": "https://vercel.com/templates/remix/turborepo-kitchensink",
"featured": true,
"maintainedByCoreTeam": true
}
3 changes: 2 additions & 1 deletion examples/with-angular/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Angular",
"description": "Minimal Turborepo example for learning the fundamentals."
"description": "Minimal Turborepo example for learning the fundamentals",
"maintainedByCoreTeam": false
}
5 changes: 5 additions & 0 deletions examples/with-berry/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Yarn Berry",
"description": "Monorepo example using Yarn Berry (Yarn 3)",
"maintainedByCoreTeam": false
}
5 changes: 3 additions & 2 deletions examples/with-changesets/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Monorepo with Changesets",
"description": "Simple Next.js monorepo preconfigured to publish packages via Changesets"
"name": "Changesets",
"description": "Configured to publish packages via Changesets",
"maintainedByCoreTeam": false
}
3 changes: 2 additions & 1 deletion examples/with-docker/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Docker",
"description": "Monorepo with an Express API and a Next.js App deployed with Docker utilizing turbo prune"
"description": "Monorepo with an Express API and a Next.js App deployed with Docker utilizing turbo prune",
"maintainedByCoreTeam": false
}
4 changes: 2 additions & 2 deletions examples/with-gatsby/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Gatsby.js",
"name": "Gatsby",
"description": "Monorepo with a Gatsby.js and a Next.js app both sharing a UI Library",
"template": "https://vercel.com/templates/gatsby/turborepo-gatsby-starter",
"featured": true
"maintainedByCoreTeam": false
}
8 changes: 3 additions & 5 deletions examples/with-nestjs/meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"name": "Next.js",
"description": "Minimal Turborepo example for learning the fundamentals.",
"template": "https://vercel.com/templates/next.js/turborepo-next-basic",
"featured": true,
"boost": true
"name": "Nest.js",
"description": "Monorepo with Nest.js",
"maintainedByCoreTeam": false
}
5 changes: 5 additions & 0 deletions examples/with-nextjs/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Next.js",
"description": "Monorepo example with Next.js applications",
"maintainedByCoreTeam": false
}
5 changes: 5 additions & 0 deletions examples/with-npm/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "npm workspaces",
"description": "Monorepo example using NPM workspaces",
"maintainedByCoreTeam": false
}
3 changes: 2 additions & 1 deletion examples/with-prisma/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Prisma",
"description": "Monorepo with a Next.js App fully configured with Prisma"
"description": "Monorepo with a Next.js App fully configured with Prisma",
"maintainedByCoreTeam": false
}
4 changes: 2 additions & 2 deletions examples/with-react-native-web/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "React Native",
"description": "Simple React Native & Next.js monorepo with a shared UI library",
"featured": true,
"template": "https://vercel.com/templates/react/turborepo-design-system"
"template": "https://vercel.com/templates/react/turborepo-design-system",
"maintainedByCoreTeam": false
}
3 changes: 2 additions & 1 deletion examples/with-rollup/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Rollup",
"description": "Monorepo with a single Next.js app sharing a UI library bundled with Rollup"
"description": "Monorepo with a single Next.js app sharing a UI library bundled with Rollup",
"maintainedByCoreTeam": false
}
2 changes: 2 additions & 0 deletions examples/with-shell-commands/meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"name": "Shell commands",
"description": "A nearly empty Turborepo - useful for creating reproductions for GitHub Issues",
"maintainedByCoreTeam": true
}
5 changes: 5 additions & 0 deletions examples/with-solid/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Solid.js",
"description": "Monorepo example with SolidJS applications",
"maintainedByCoreTeam": false
}
2 changes: 0 additions & 2 deletions examples/with-svelte/meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"name": "SvelteKit",
"description": "Monorepo with multiple SvelteKit apps sharing a UI Library",
"featured": true,
"template": "https://vercel.com/templates/svelte/turborepo-sveltekit-starter",
"boost": true,
"maintainedByCoreTeam": true
}
Loading
Loading