diff --git a/examples/basics/.gitignore b/examples/basics/.gitignore new file mode 100644 index 000000000..7329a851d --- /dev/null +++ b/examples/basics/.gitignore @@ -0,0 +1,20 @@ +# build output +dist/ +.output/ + +# 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 diff --git a/examples/basics/.npmrc b/examples/basics/.npmrc new file mode 100644 index 000000000..ef83021af --- /dev/null +++ b/examples/basics/.npmrc @@ -0,0 +1,2 @@ +# Expose Astro dependencies for `pnpm` users +shamefully-hoist=true diff --git a/examples/basics/.stackblitzrc b/examples/basics/.stackblitzrc new file mode 100644 index 000000000..43798ecff --- /dev/null +++ b/examples/basics/.stackblitzrc @@ -0,0 +1,6 @@ +{ + "startCommand": "npm start", + "env": { + "ENABLE_CJS_IMPORTS": true + } +} \ No newline at end of file diff --git a/examples/basics/.vscode/extensions.json b/examples/basics/.vscode/extensions.json new file mode 100644 index 000000000..22a15055d --- /dev/null +++ b/examples/basics/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/examples/basics/.vscode/launch.json b/examples/basics/.vscode/launch.json new file mode 100644 index 000000000..d64220976 --- /dev/null +++ b/examples/basics/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "command": "./node_modules/.bin/astro dev", + "name": "Development server", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/examples/basics/README.md b/examples/basics/README.md new file mode 100644 index 000000000..15f6eb693 --- /dev/null +++ b/examples/basics/README.md @@ -0,0 +1,42 @@ +# Welcome to [Astro](https://astro.build) + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/starter) + +> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +``` +/ +├── public/ +│ └── favicon.ico +├── src/ +│ ├── components/ +│ │ └── Layout.astro +│ └── pages/ +│ └── index.astro +└── package.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. + +There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components or layouts. + +Any static assets, like images, can be placed in the `public/` directory. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +| :---------------- | :------------------------------------------- | +| `npm install` | Installs dependencies | +| `npm run dev` | Starts local dev server at `localhost:3000` | +| `npm run build` | Build your production site to `./dist/` | +| `npm run preview` | Preview your build locally, before deploying | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://github.com/withastro/astro) or jump into our [Discord server](https://astro.build/chat). diff --git a/examples/basics/astro.config.mjs b/examples/basics/astro.config.mjs new file mode 100644 index 000000000..882e6515a --- /dev/null +++ b/examples/basics/astro.config.mjs @@ -0,0 +1,4 @@ +import { defineConfig } from 'astro/config'; + +// https://astro.build/config +export default defineConfig({}); diff --git a/examples/basics/package.json b/examples/basics/package.json new file mode 100644 index 000000000..47641b465 --- /dev/null +++ b/examples/basics/package.json @@ -0,0 +1,14 @@ +{ + "name": "@example/basics", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview" + }, + "devDependencies": { + "astro": "^1.0.0-beta.17" + } +} diff --git a/examples/basics/public/favicon.ico b/examples/basics/public/favicon.ico new file mode 100644 index 000000000..578ad458b Binary files /dev/null and b/examples/basics/public/favicon.ico differ diff --git a/examples/basics/sandbox.config.json b/examples/basics/sandbox.config.json new file mode 100644 index 000000000..9178af77d --- /dev/null +++ b/examples/basics/sandbox.config.json @@ -0,0 +1,11 @@ +{ + "infiniteLoopProtection": true, + "hardReloadOnChange": false, + "view": "browser", + "template": "node", + "container": { + "port": 3000, + "startScript": "start", + "node": "14" + } +} diff --git a/examples/basics/src/components/Layout.astro b/examples/basics/src/components/Layout.astro new file mode 100644 index 000000000..cf1c00262 --- /dev/null +++ b/examples/basics/src/components/Layout.astro @@ -0,0 +1,55 @@ +--- +export interface Props { + title: string; +} + +const { title } = Astro.props as Props; +--- + + + + + + + + {title} + + + + + + + diff --git a/examples/basics/src/pages/index.astro b/examples/basics/src/pages/index.astro new file mode 100644 index 000000000..605f8cf2c --- /dev/null +++ b/examples/basics/src/pages/index.astro @@ -0,0 +1,174 @@ +--- +import Layout from '../components/Layout.astro'; +--- + + +
+

Welcome to Astro

+

Your first mission: tweak this message to try our hot module reloading. Check the src/pages directory!

+ +
+
+ + diff --git a/examples/basics/tsconfig.json b/examples/basics/tsconfig.json new file mode 100644 index 000000000..8e881cf9c --- /dev/null +++ b/examples/basics/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "moduleResolution": "node" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d75356fb5..40b9fd2dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,6 +43,12 @@ importers: turbo: 1.2.5 typescript: 4.6.3 + examples/basics: + specifiers: + astro: ^1.0.0-beta.17 + devDependencies: + astro: link:../../packages/astro + examples/blog: specifiers: '@astrojs/preact': ^0.1.2