mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
feat: add astro template
This commit is contained in:
5
.changeset/happy-days-drum.md
Normal file
5
.changeset/happy-days-drum.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"shadcn": major
|
||||
---
|
||||
|
||||
add astro template support
|
||||
@@ -25,10 +25,14 @@ const VITE_LOGO =
|
||||
const LARAVEL_LOGO =
|
||||
'<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Laravel</title><path d="M23.642 5.43a.364.364 0 0 1 .014.1v5.149c0 .135-.073.26-.189.326l-4.323 2.49v4.934a.378.378 0 0 1-.188.326L9.93 23.949a.316.316 0 0 1-.066.027c-.008.002-.016.008-.024.01a.348.348 0 0 1-.192 0c-.011-.002-.02-.008-.03-.012-.02-.008-.042-.014-.062-.025L.533 18.755a.376.376 0 0 1-.189-.326V2.974c0-.033.005-.066.014-.098.003-.012.01-.02.014-.032a.369.369 0 0 1 .023-.058c.004-.013.015-.022.023-.033l.033-.045c.012-.01.025-.018.037-.027.014-.012.027-.024.041-.034h.001L5.044.05a.375.375 0 0 1 .375 0L9.933 2.697h.002c.015.01.027.021.04.033l.038.027c.013.014.02.03.033.045.008.011.02.021.025.033.01.02.017.038.024.058.003.011.01.021.013.032.01.031.014.064.014.098v9.652l3.76-2.164V5.527c0-.033.004-.066.013-.098.003-.01.01-.02.013-.032a.487.487 0 0 1 .024-.059c.007-.012.018-.02.025-.033.012-.015.021-.03.033-.043.012-.012.025-.02.037-.028.014-.011.026-.023.041-.032h.001l4.513-2.647a.375.375 0 0 1 .375 0l4.513 2.647c.016.011.029.021.042.031.012.01.025.018.036.028.013.014.022.03.034.045.008.012.019.021.024.033a.3.3 0 0 1 .024.06c.006.01.012.021.015.032zm-.74 5.032V5.860l-1.578.908-2.182 1.256v4.603zm-4.514 7.75v-4.605l-2.148 1.227-6.876 3.93v4.649zm-17.642-15.3v15.15l8.25 4.757v-4.645L4.699 15.87l-.003-.002-.002-.001c-.014-.01-.025-.021-.04-.033-.012-.01-.026-.018-.036-.028l-.001-.002c-.013-.012-.021-.028-.032-.043-.01-.013-.022-.023-.03-.037v-.002c-.01-.014-.016-.032-.023-.048-.006-.012-.016-.023-.02-.035l-.002-.001c-.005-.018-.008-.037-.011-.057L4.5 15.58v-9.51l-2.182-1.256-1.578-.908zm4.322-2.474L1.313 2.974l3.756 2.163 3.755-2.163zm2.068 11.22 2.182-1.256V1.974L7.937 3.23 5.755 4.486v11.186zm10.895-7.583-3.755 2.163 3.755 2.164 3.755-2.164zm-.375 4.976-2.182-1.256-1.578-.908v4.603l2.182 1.256 1.578.908zm-8.438 6.186 5.494-3.14 2.944-1.682-3.755-2.163-4.323 2.489-4.136 2.384z"/></svg>'
|
||||
|
||||
const ASTRO_LOGO =
|
||||
'<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Astro</title><path d="M8.358 20.162c-1.186-1.07-1.532-3.316-1.038-4.944.856 1.026 2.043 1.352 3.272 1.535 1.897.283 3.76.177 5.522-.678.202-.098.388-.229.608-.36.166.473.209.95.151 1.437-.14 1.16-.738 2.06-1.672 2.783-.514.398-1.07.755-1.61 1.127-1.623 1.12-2.087 2.399-1.39 4.238.018.046.03.094.063.2-.89-.477-1.525-1.13-1.924-2.004-.427-.938-.51-1.92-.348-2.938.073-.468.076-.946-.025-1.4-.232-1.04-.953-1.681-1.96-1.69-.598-.005-1.134.348-1.399.904-.381.799-.244 1.554.225 2.274.257.394.576.74.525 1.516"/><path d="M15.807 2.001a.075.075 0 0 1 .087.048c.009.025.005.053-.01.074l-.064.082c-3.182 4.06-4.16 8.478-2.936 13.254.014.055.04.13-.058.163-.096.033-.156-.04-.188-.107a10 10 0 0 1-.397-.96c-1.15-3.2-.594-6.202 1.094-9.051.469-.793.994-1.55 1.546-2.292l.192-.247c.075-.097.156-.18.257-.254A3 3 0 0 1 15.695 2z"/></svg>'
|
||||
|
||||
export const TEMPLATES = [
|
||||
[
|
||||
{ value: "next", title: "Next.js", logo: NEXT_LOGO },
|
||||
{ value: "vite", title: "Vite", logo: VITE_LOGO },
|
||||
{ value: "astro", title: "Astro", logo: ASTRO_LOGO },
|
||||
],
|
||||
[
|
||||
{ value: "start", title: "TanStack Start", logo: START_LOGO },
|
||||
|
||||
@@ -73,6 +73,8 @@ const designSystemSearchParams = {
|
||||
"react-router-monorepo",
|
||||
"vite",
|
||||
"vite-monorepo",
|
||||
"astro",
|
||||
"astro-monorepo",
|
||||
"laravel",
|
||||
] as const).withDefault("next"),
|
||||
rtl: parseAsBoolean.withDefault(false),
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
"[Changelog](/docs/changelog)",
|
||||
"[llms.txt](/llms.txt)",
|
||||
"legacy",
|
||||
"new"
|
||||
"!new"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: Your project is ready!
|
||||
description: You've created a new project with shadcn/ui. Here's what to do next.
|
||||
description: You've created a new project with shadcn/ui.
|
||||
---
|
||||
|
||||
Here are the next steps to start building.
|
||||
Here's a few things you can do to get started building with shadcn/ui.
|
||||
|
||||
## Add Components
|
||||
|
||||
@@ -39,19 +39,61 @@ Browse all components on the [Components](/docs/components) page.
|
||||
|
||||
## Customize Your Theme
|
||||
|
||||
You can create a custom theme visually on [ui.shadcn.com](https://ui.shadcn.com) and apply it to your project using a preset code.
|
||||
You can edit your theme directly in your CSS file. Learn more about [Theming](/docs/theming) and how to use CSS variables or utility classes.
|
||||
|
||||
If you want to try a new preset, you can create a custom theme visually on [ui.shadcn.com](https://ui.shadcn.com) and apply it to your project using a preset code.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest init --preset a2r6bw
|
||||
npx shadcn@latest init --preset [CODE]
|
||||
```
|
||||
|
||||
You can also edit your theme directly in your CSS file. Learn more about [Theming](/docs/theming).
|
||||
## Add a block
|
||||
|
||||
## Configure Your Project
|
||||
You can add a block to your project using the CLI.
|
||||
|
||||
Your project settings are stored in `components.json`. You can change import aliases, the icon library, or switch between base primitives.
|
||||
```bash
|
||||
npx shadcn@latest add login-03
|
||||
```
|
||||
|
||||
Learn more about [components.json](/docs/components-json).
|
||||
This will add the `login-03` block to your project. Import and use it in your code.
|
||||
|
||||
```tsx title="app/page.tsx"
|
||||
import { Login03 } from "@/components/login-03"
|
||||
|
||||
export default function Home() {
|
||||
return <Login03 />
|
||||
}
|
||||
```
|
||||
|
||||
## Install from Registries
|
||||
|
||||
shadcn/ui has a growing ecosystem of community registries. You can install components from any registry URL using the CLI.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add @[registry]/[name]
|
||||
```
|
||||
|
||||
Browse the [Registry Directory](/docs/directory) for a list of available registries.
|
||||
|
||||
## Use AI to Build
|
||||
|
||||
shadcn/ui is designed to work with AI. Your AI assistant can read the component source code in your project, understand the APIs, and compose them together to build pages and features.
|
||||
|
||||
Here are some example prompts to try:
|
||||
|
||||
- _"Create a signup page with a form for entering name, email and password."_
|
||||
- _"Create a settings page with a form for updating profile information."_
|
||||
- _"Build a dashboard with a header, stats cards, and a data table."_
|
||||
|
||||
## Install the shadcn Skills
|
||||
|
||||
Install the shadcn skill in your AI assistant. This will give your AI assistant access to the full component registry, documentation, and search.
|
||||
|
||||
```bash
|
||||
npx skills add shadcn-ui/ui
|
||||
```
|
||||
|
||||
Learn more about the [shadcn skill](/docs/skill).
|
||||
|
||||
## Connect the MCP Server
|
||||
|
||||
@@ -62,23 +104,3 @@ npx shadcn@latest mcp init
|
||||
```
|
||||
|
||||
Learn more on the [MCP Server](/docs/mcp) page.
|
||||
|
||||
## Use AI to Build
|
||||
|
||||
shadcn/ui is designed to work with AI. Your AI assistant can read the component source code in your project, understand the APIs, and compose them together to build pages and features.
|
||||
|
||||
Here are some example prompts to try:
|
||||
|
||||
- _"Create a settings page with a form for updating profile information."_
|
||||
- _"Add a sidebar navigation with collapsible groups."_
|
||||
- _"Build a dashboard with a header, stats cards, and a data table."_
|
||||
|
||||
## Install from Registries
|
||||
|
||||
shadcn/ui has a growing ecosystem of community registries. You can install components from any registry URL using the CLI.
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add https://example.com/r/my-component.json
|
||||
```
|
||||
|
||||
Browse registries on the [Directory](/docs/directory) page. You can also [build and publish your own registry](/docs/registry).
|
||||
|
||||
@@ -104,6 +104,8 @@ export const designSystemConfigSchema = z
|
||||
"vite-monorepo",
|
||||
"react-router-monorepo",
|
||||
"start-monorepo",
|
||||
"astro",
|
||||
"astro-monorepo",
|
||||
])
|
||||
.default("next")
|
||||
.optional(),
|
||||
|
||||
@@ -27,10 +27,12 @@ const TEMPLATE_NAMES = [
|
||||
"vite-app",
|
||||
"react-router-app",
|
||||
"start-app",
|
||||
"astro-app",
|
||||
"next-monorepo",
|
||||
"vite-monorepo",
|
||||
"react-router-monorepo",
|
||||
"start-monorepo",
|
||||
"astro-monorepo",
|
||||
]
|
||||
|
||||
// Collect paths for batch prettier formatting at the end.
|
||||
|
||||
60
packages/shadcn/src/templates/astro.ts
Normal file
60
packages/shadcn/src/templates/astro.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import dedent from "dedent"
|
||||
|
||||
import { createTemplate } from "./create-template"
|
||||
import { fontsourceMonorepoInit } from "./monorepo"
|
||||
|
||||
export const astro = createTemplate({
|
||||
name: "astro",
|
||||
title: "Astro",
|
||||
defaultProjectName: "astro-app",
|
||||
templateDir: "astro-app",
|
||||
frameworks: ["astro"],
|
||||
create: async () => {
|
||||
// Empty for now.
|
||||
},
|
||||
files: [
|
||||
{
|
||||
type: "registry:page",
|
||||
path: "src/pages/index.astro",
|
||||
target: "src/pages/index.astro",
|
||||
content: dedent`---
|
||||
import Layout from "@/layouts/main.astro"
|
||||
import { ComponentExample } from "@/components/component-example"
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<ComponentExample client:load />
|
||||
</Layout>
|
||||
`,
|
||||
},
|
||||
],
|
||||
monorepo: {
|
||||
templateDir: "astro-monorepo",
|
||||
packageManager: "pnpm",
|
||||
installArgs: ["--no-frozen-lockfile"],
|
||||
init: fontsourceMonorepoInit,
|
||||
files: [
|
||||
{
|
||||
type: "registry:page",
|
||||
path: "src/pages/index.astro",
|
||||
target: "src/pages/index.astro",
|
||||
content: dedent`---
|
||||
import "@workspace/ui/globals.css"
|
||||
import { ComponentExample } from "@/components/component-example"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<ComponentExample client:load />
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
@@ -1,3 +1,4 @@
|
||||
import { astro } from "./astro"
|
||||
import { next } from "./next"
|
||||
import { reactRouter } from "./react-router"
|
||||
import { start } from "./start"
|
||||
@@ -15,6 +16,7 @@ export const templates = {
|
||||
vite,
|
||||
start,
|
||||
"react-router": reactRouter,
|
||||
astro,
|
||||
}
|
||||
|
||||
// Resolve a template key from a detected framework name.
|
||||
|
||||
23
templates/astro-app/.gitignore
vendored
Normal file
23
templates/astro-app/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# build output
|
||||
dist/
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
||||
# jetbrains setting folder
|
||||
.idea/
|
||||
6
templates/astro-app/.prettierignore
Normal file
6
templates/astro-app/.prettierignore
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
.pnpm-store/
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
19
templates/astro-app/.prettierrc
Normal file
19
templates/astro-app/.prettierrc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"endOfLine": "lf",
|
||||
"semi": false,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 80,
|
||||
"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
|
||||
"tailwindStylesheet": "src/styles/global.css",
|
||||
"tailwindFunctions": ["cn", "cva"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.astro",
|
||||
"options": {
|
||||
"parser": "astro"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
36
templates/astro-app/README.md
Normal file
36
templates/astro-app/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Astro + React + TypeScript + shadcn/ui
|
||||
|
||||
This is a template for a new Astro project with React, TypeScript, and shadcn/ui.
|
||||
|
||||
## Adding components
|
||||
|
||||
To add components to your app, run the following command:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button
|
||||
```
|
||||
|
||||
This will place the ui components in the `src/components` directory.
|
||||
|
||||
## Using components
|
||||
|
||||
To use the components in your app, import them in an `.astro` file:
|
||||
|
||||
```astro
|
||||
---
|
||||
import { Button } from "@/components/ui/button"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="grid h-screen place-items-center content-center">
|
||||
<Button>Button</Button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
13
templates/astro-app/astro.config.mjs
Normal file
13
templates/astro-app/astro.config.mjs
Normal file
@@ -0,0 +1,13 @@
|
||||
// @ts-check
|
||||
|
||||
import tailwindcss from "@tailwindcss/vite"
|
||||
import { defineConfig } from "astro/config"
|
||||
import react from "@astrojs/react"
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
integrations: [react()],
|
||||
})
|
||||
23
templates/astro-app/eslint.config.js
Normal file
23
templates/astro-app/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import js from "@eslint/js"
|
||||
import globals from "globals"
|
||||
import reactHooks from "eslint-plugin-react-hooks"
|
||||
import reactRefresh from "eslint-plugin-react-refresh"
|
||||
import tseslint from "typescript-eslint"
|
||||
import { defineConfig, globalIgnores } from "eslint/config"
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(["dist", ".astro"]),
|
||||
{
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
37
templates/astro-app/package.json
Normal file
37
templates/astro-app/package.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "astro-app",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,astro}\"",
|
||||
"typecheck": "astro check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/react": "^4.4.2",
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"astro": "^5.17.1",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"tailwindcss": "^4.1.18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"prettier": "^3.8.1",
|
||||
"prettier-plugin-astro": "^0.14.1",
|
||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.46.4"
|
||||
}
|
||||
}
|
||||
3
templates/astro-app/public/favicon.svg
Normal file
3
templates/astro-app/public/favicon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
|
||||
<path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a1 1 0 0 0 .67-.55L18 14l4.41 8.76a1 1 0 0 0 .67.55l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 286 B |
15
templates/astro-app/src/layouts/main.astro
Normal file
15
templates/astro-app/src/layouts/main.astro
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import "@/styles/global.css"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
20
templates/astro-app/src/pages/index.astro
Normal file
20
templates/astro-app/src/pages/index.astro
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
import Layout from "@/layouts/main.astro"
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<div class="flex min-h-svh p-6">
|
||||
<div class="max-w-md text-sm leading-loose">
|
||||
<h1 class="font-medium">Project ready!</h1>
|
||||
<p>You may now add components and start building.</p>
|
||||
<a
|
||||
href="https://ui.shadcn.com/docs/new"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="mt-2 inline-flex text-primary underline underline-offset-4"
|
||||
>
|
||||
Read the docs
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>
|
||||
1
templates/astro-app/src/styles/global.css
Normal file
1
templates/astro-app/src/styles/global.css
Normal file
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
13
templates/astro-app/tsconfig.json
Normal file
13
templates/astro-app/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "react",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
33
templates/astro-monorepo/.gitignore
vendored
Normal file
33
templates/astro-monorepo/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# Dependencies
|
||||
node_modules
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Testing
|
||||
coverage
|
||||
|
||||
# Turbo
|
||||
.turbo
|
||||
|
||||
# Vercel
|
||||
.vercel
|
||||
|
||||
# Build Outputs
|
||||
dist
|
||||
|
||||
# Astro
|
||||
.astro
|
||||
|
||||
# Debug
|
||||
npm-debug.log*
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
1
templates/astro-monorepo/.npmrc
Normal file
1
templates/astro-monorepo/.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
6
templates/astro-monorepo/.prettierignore
Normal file
6
templates/astro-monorepo/.prettierignore
Normal file
@@ -0,0 +1,6 @@
|
||||
dist/
|
||||
node_modules/
|
||||
.turbo/
|
||||
coverage/
|
||||
pnpm-lock.yaml
|
||||
.pnpm-store/
|
||||
19
templates/astro-monorepo/.prettierrc
Normal file
19
templates/astro-monorepo/.prettierrc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"endOfLine": "lf",
|
||||
"semi": false,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "es5",
|
||||
"printWidth": 80,
|
||||
"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
|
||||
"tailwindStylesheet": "packages/ui/src/styles/globals.css",
|
||||
"tailwindFunctions": ["cn", "cva"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.astro",
|
||||
"options": {
|
||||
"parser": "astro"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
39
templates/astro-monorepo/README.md
Normal file
39
templates/astro-monorepo/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Astro + React + TypeScript + shadcn/ui (Monorepo)
|
||||
|
||||
This is a monorepo template for Astro with React, TypeScript, and shadcn/ui.
|
||||
|
||||
## Structure
|
||||
|
||||
- `apps/web` - Astro application
|
||||
- `packages/ui` - Shared UI components (shadcn/ui)
|
||||
|
||||
## Adding components
|
||||
|
||||
To add components, run the following command from the root:
|
||||
|
||||
```bash
|
||||
npx shadcn@latest add button -c apps/web
|
||||
```
|
||||
|
||||
## Using components
|
||||
|
||||
To use the components in your app, import them in an `.astro` file:
|
||||
|
||||
```astro
|
||||
---
|
||||
import { Button } from "@workspace/ui/components/button"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="grid h-screen place-items-center content-center">
|
||||
<Button>Button</Button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
13
templates/astro-monorepo/apps/web/astro.config.mjs
Normal file
13
templates/astro-monorepo/apps/web/astro.config.mjs
Normal file
@@ -0,0 +1,13 @@
|
||||
// @ts-check
|
||||
|
||||
import tailwindcss from "@tailwindcss/vite"
|
||||
import { defineConfig } from "astro/config"
|
||||
import react from "@astrojs/react"
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
integrations: [react()],
|
||||
})
|
||||
20
templates/astro-monorepo/apps/web/components.json
Normal file
20
templates/astro-monorepo/apps/web/components.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "radix-nova",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "../../packages/ui/src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"aliases": {
|
||||
"components": "@/components",
|
||||
"hooks": "@/hooks",
|
||||
"lib": "@/lib",
|
||||
"utils": "@workspace/ui/lib/utils",
|
||||
"ui": "@workspace/ui/components"
|
||||
}
|
||||
}
|
||||
23
templates/astro-monorepo/apps/web/eslint.config.js
Normal file
23
templates/astro-monorepo/apps/web/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import js from "@eslint/js"
|
||||
import globals from "globals"
|
||||
import reactHooks from "eslint-plugin-react-hooks"
|
||||
import reactRefresh from "eslint-plugin-react-refresh"
|
||||
import tseslint from "typescript-eslint"
|
||||
import { defineConfig, globalIgnores } from "eslint/config"
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(["dist", ".astro"]),
|
||||
{
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
35
templates/astro-monorepo/apps/web/package.json
Normal file
35
templates/astro-monorepo/apps/web/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "web",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro",
|
||||
"lint": "eslint",
|
||||
"format": "prettier --write \"**/*.{ts,tsx,astro}\"",
|
||||
"typecheck": "astro check"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/react": "^4.4.2",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@workspace/ui": "workspace:*",
|
||||
"astro": "^5.17.1",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"@types/node": "^25.1.0",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^17.2.0",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.54.0"
|
||||
}
|
||||
}
|
||||
3
templates/astro-monorepo/apps/web/public/favicon.svg
Normal file
3
templates/astro-monorepo/apps/web/public/favicon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
|
||||
<path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a1 1 0 0 0 .67-.55L18 14l4.41 8.76a1 1 0 0 0 .67.55l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 286 B |
15
templates/astro-monorepo/apps/web/src/layouts/main.astro
Normal file
15
templates/astro-monorepo/apps/web/src/layouts/main.astro
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
import "@workspace/ui/globals.css"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
0
templates/astro-monorepo/apps/web/src/lib/.gitkeep
Normal file
0
templates/astro-monorepo/apps/web/src/lib/.gitkeep
Normal file
28
templates/astro-monorepo/apps/web/src/pages/index.astro
Normal file
28
templates/astro-monorepo/apps/web/src/pages/index.astro
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
import "@workspace/ui/globals.css"
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<title>Astro App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="flex min-h-svh p-6">
|
||||
<div class="max-w-md text-sm leading-loose">
|
||||
<h1 class="font-medium">Project ready!</h1>
|
||||
<p>You may now add components and start building.</p>
|
||||
<a
|
||||
href="https://ui.shadcn.com/docs/new"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="mt-2 inline-flex text-primary underline underline-offset-4"
|
||||
>
|
||||
Read the docs
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
14
templates/astro-monorepo/apps/web/tsconfig.json
Normal file
14
templates/astro-monorepo/apps/web/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "react",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"],
|
||||
"@workspace/ui/*": ["../../packages/ui/src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
23
templates/astro-monorepo/package.json
Normal file
23
templates/astro-monorepo/package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "astro-monorepo",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "turbo build",
|
||||
"dev": "turbo dev",
|
||||
"lint": "turbo lint",
|
||||
"format": "turbo format",
|
||||
"typecheck": "turbo typecheck"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^3.8.1",
|
||||
"prettier-plugin-astro": "^0.14.1",
|
||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||
"turbo": "^2.8.8",
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"packageManager": "pnpm@9.0.6",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
}
|
||||
20
templates/astro-monorepo/packages/ui/components.json
Normal file
20
templates/astro-monorepo/packages/ui/components.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://ui.shadcn.com/schema.json",
|
||||
"style": "radix-nova",
|
||||
"rsc": false,
|
||||
"tsx": true,
|
||||
"tailwind": {
|
||||
"config": "",
|
||||
"css": "src/styles/globals.css",
|
||||
"baseColor": "neutral",
|
||||
"cssVariables": true
|
||||
},
|
||||
"iconLibrary": "lucide",
|
||||
"aliases": {
|
||||
"components": "@workspace/ui/components",
|
||||
"utils": "@workspace/ui/lib/utils",
|
||||
"hooks": "@workspace/ui/hooks",
|
||||
"lib": "@workspace/ui/lib",
|
||||
"ui": "@workspace/ui/components"
|
||||
}
|
||||
}
|
||||
23
templates/astro-monorepo/packages/ui/eslint.config.js
Normal file
23
templates/astro-monorepo/packages/ui/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import js from "@eslint/js"
|
||||
import globals from "globals"
|
||||
import reactHooks from "eslint-plugin-react-hooks"
|
||||
import reactRefresh from "eslint-plugin-react-refresh"
|
||||
import tseslint from "typescript-eslint"
|
||||
import { defineConfig, globalIgnores } from "eslint/config"
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(["dist"]),
|
||||
{
|
||||
files: ["**/*.{ts,tsx}"],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
37
templates/astro-monorepo/packages/ui/package.json
Normal file
37
templates/astro-monorepo/packages/ui/package.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@workspace/ui",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint",
|
||||
"format": "prettier --write \"**/*.{ts,tsx}\"",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"@turbo/gen": "^2.8.1",
|
||||
"@types/node": "^25.1.0",
|
||||
"@types/react": "^19.2.10",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^17.2.0",
|
||||
"typescript-eslint": "^8.54.0",
|
||||
"tailwindcss": "^4.1.18",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"exports": {
|
||||
"./globals.css": "./src/styles/globals.css",
|
||||
"./lib/*": "./src/lib/*.ts",
|
||||
"./components/*": "./src/components/*.tsx",
|
||||
"./hooks/*": "./src/hooks/*.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@import "tailwindcss";
|
||||
@source "../../../apps/**/*.{ts,tsx,astro}";
|
||||
@source "../../../components/**/*.{ts,tsx}";
|
||||
@source "../**/*.{ts,tsx}";
|
||||
18
templates/astro-monorepo/packages/ui/tsconfig.json
Normal file
18
templates/astro-monorepo/packages/ui/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@workspace/ui/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
14
templates/astro-monorepo/packages/ui/tsconfig.lint.json
Normal file
14
templates/astro-monorepo/packages/ui/tsconfig.lint.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src", "turbo"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
3
templates/astro-monorepo/pnpm-workspace.yaml
Normal file
3
templates/astro-monorepo/pnpm-workspace.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
packages:
|
||||
- "apps/*"
|
||||
- "packages/*"
|
||||
9
templates/astro-monorepo/tsconfig.json
Normal file
9
templates/astro-monorepo/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"skipLibCheck": true,
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
15
templates/astro-monorepo/turbo.json
Normal file
15
templates/astro-monorepo/turbo.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"ui": "tui",
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
||||
"outputs": ["dist/**"]
|
||||
},
|
||||
"lint": { "dependsOn": ["^lint"] },
|
||||
"format": { "dependsOn": ["^format"] },
|
||||
"typecheck": { "dependsOn": ["^typecheck"] },
|
||||
"dev": { "cache": false, "persistent": true }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user