diff --git a/examples/deno/.npmrc b/examples/deno/.npmrc new file mode 100644 index 000000000000..ef83021af3ec --- /dev/null +++ b/examples/deno/.npmrc @@ -0,0 +1,2 @@ +# Expose Astro dependencies for `pnpm` users +shamefully-hoist=true diff --git a/examples/deno/.stackblitzrc b/examples/deno/.stackblitzrc new file mode 100644 index 000000000000..43798ecff844 --- /dev/null +++ b/examples/deno/.stackblitzrc @@ -0,0 +1,6 @@ +{ + "startCommand": "npm start", + "env": { + "ENABLE_CJS_IMPORTS": true + } +} \ No newline at end of file diff --git a/examples/deno/.vscode/extensions.json b/examples/deno/.vscode/extensions.json new file mode 100644 index 000000000000..22a15055d638 --- /dev/null +++ b/examples/deno/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/examples/deno/.vscode/launch.json b/examples/deno/.vscode/launch.json new file mode 100644 index 000000000000..d6422097621f --- /dev/null +++ b/examples/deno/.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/deno/README.md b/examples/deno/README.md new file mode 100644 index 000000000000..9a7d7da61cd4 --- /dev/null +++ b/examples/deno/README.md @@ -0,0 +1,49 @@ +# 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/basics) + +> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! + +![basics](https://user-images.githubusercontent.com/4677417/186188965-73453154-fdec-4d6b-9c34-cb35c248ae5b.png) + + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +``` +/ +├── public/ +│ └── favicon.svg +├── src/ +│ ├── components/ +│ │ └── Layout.astro +│ └── pages/ +│ └── index.astro +├── package.json +└── tsconfig.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. + +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 | +| | (preview uses Deno CLI) | +| `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` | +| `npm run astro --help` | Get help using the Astro CLI | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat). diff --git a/examples/deno/astro.config.mjs b/examples/deno/astro.config.mjs new file mode 100644 index 000000000000..71783d132ad9 --- /dev/null +++ b/examples/deno/astro.config.mjs @@ -0,0 +1,9 @@ +import { defineConfig } from 'astro/config'; + +import deno from "@astrojs/deno"; + +// https://astro.build/config +export default defineConfig({ + output: "server", + adapter: deno() +}); \ No newline at end of file diff --git a/examples/deno/package.json b/examples/deno/package.json new file mode 100644 index 000000000000..5951a77e1641 --- /dev/null +++ b/examples/deno/package.json @@ -0,0 +1,18 @@ +{ + "name": "@example/deno", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "deno run --allow-net --allow-read ./dist/server/entry.mjs", + "astro": "astro" + }, + "dependencies": { + "astro": "^1.1.5" + }, + "devDependencies": { + "@astrojs/deno": "^1.0.1" + } +} diff --git a/examples/deno/public/favicon.ico b/examples/deno/public/favicon.ico new file mode 100644 index 000000000000..578ad458b890 Binary files /dev/null and b/examples/deno/public/favicon.ico differ diff --git a/examples/deno/sandbox.config.json b/examples/deno/sandbox.config.json new file mode 100644 index 000000000000..9178af77d7de --- /dev/null +++ b/examples/deno/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/deno/src/components/Layout.astro b/examples/deno/src/components/Layout.astro new file mode 100644 index 000000000000..b8fc659fe60c --- /dev/null +++ b/examples/deno/src/components/Layout.astro @@ -0,0 +1,55 @@ +--- +export interface Props { + title: string; +} + +const { title } = Astro.props as Props; +--- + + + + + + + + {title} + + + + + + + diff --git a/examples/deno/src/pages/index.astro b/examples/deno/src/pages/index.astro new file mode 100644 index 000000000000..2a0bf7d07718 --- /dev/null +++ b/examples/deno/src/pages/index.astro @@ -0,0 +1,174 @@ +--- +import Layout from '../components/Layout.astro'; +--- + + +
+

Welcome to Astro on Deno

+

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

+ +
+
+ + diff --git a/examples/deno/tsconfig.json b/examples/deno/tsconfig.json new file mode 100644 index 000000000000..d78f81ec4e8e --- /dev/null +++ b/examples/deno/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "astro/tsconfigs/base" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad1c1c3d0143..5f69176bc1d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,15 @@ importers: examples/component/packages/my-component: specifiers: {} + examples/deno: + specifiers: + '@astrojs/deno': ^1.0.1 + astro: ^1.1.5 + dependencies: + astro: link:../../packages/astro + devDependencies: + '@astrojs/deno': link:../../packages/integrations/deno + examples/docs: specifiers: '@algolia/client-search': ^4.13.1