diff --git a/examples/component/.gitignore b/examples/component/.gitignore new file mode 100644 index 000000000..d436c6dad --- /dev/null +++ b/examples/component/.gitignore @@ -0,0 +1,18 @@ +# build output +dist + +# dependencies +node_modules/ +.snowpack/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store diff --git a/examples/component/.npmrc b/examples/component/.npmrc new file mode 100644 index 000000000..65922326b --- /dev/null +++ b/examples/component/.npmrc @@ -0,0 +1,2 @@ +## force pnpm to hoist +shamefully-hoist = true diff --git a/examples/component/.stackblitzrc b/examples/component/.stackblitzrc new file mode 100644 index 000000000..43798ecff --- /dev/null +++ b/examples/component/.stackblitzrc @@ -0,0 +1,6 @@ +{ + "startCommand": "npm start", + "env": { + "ENABLE_CJS_IMPORTS": true + } +} \ No newline at end of file diff --git a/examples/component/README.md b/examples/component/README.md new file mode 100644 index 000000000..76492bd28 --- /dev/null +++ b/examples/component/README.md @@ -0,0 +1,45 @@ +# Astro Starter Kit: Component + +``` +npm init astro -- --template component +``` + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/component) + +> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun! + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +``` +/ +├── demo/ +│ ├── public/ +│ └── src/ +│ └── pages/ +│ └── index.astro +└── packages/ + └── my-component/ + ├── index.js + └── package.json +``` + +This project uses **workspaces** to develop a single package, `@example/my-component`, from `packages/my-component`. It also includes a `demo` Astro site for testing and demonstrating the component. + + + +## 🧞 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/component/astro.config.mjs b/examples/component/astro.config.mjs new file mode 100644 index 000000000..94846abde --- /dev/null +++ b/examples/component/astro.config.mjs @@ -0,0 +1,13 @@ +// Full Astro Configuration API Documentation: +// https://docs.astro.build/reference/configuration-reference + +// @type-check enabled! +// VSCode and other TypeScript-enabled text editors will provide auto-completion, +// helpful tooltips, and warnings if your exported object is invalid. +// You can disable this by removing "@ts-check" and `@type` comments below. + +// @ts-check +export default /** @type {import('astro').AstroUserConfig} */ ({ + // Comment out "renderers: []" to enable Astro's default component support. + renderers: [], +}); diff --git a/examples/component/demo/package.json b/examples/component/demo/package.json new file mode 100644 index 000000000..575002652 --- /dev/null +++ b/examples/component/demo/package.json @@ -0,0 +1,14 @@ +{ + "name": "@example/my-component-demo", + "version": "0.0.1", + "private": true, + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview" + }, + "devDependencies": { + "astro": "^0.21.11" + } +} diff --git a/examples/component/demo/public/favicon.ico b/examples/component/demo/public/favicon.ico new file mode 100644 index 000000000..578ad458b Binary files /dev/null and b/examples/component/demo/public/favicon.ico differ diff --git a/examples/component/demo/public/robots.txt b/examples/component/demo/public/robots.txt new file mode 100644 index 000000000..1f53798bb --- /dev/null +++ b/examples/component/demo/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/examples/component/demo/src/pages/index.astro b/examples/component/demo/src/pages/index.astro new file mode 100644 index 000000000..96ca814e3 --- /dev/null +++ b/examples/component/demo/src/pages/index.astro @@ -0,0 +1,29 @@ +--- +import * as Component from '@example/my-component' +--- + + +
+ + +