summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2021-06-02 11:35:28 -0500
committerGravatar GitHub <noreply@github.com> 2021-06-02 11:35:28 -0500
commit94eac19888398e91d436cf31867ba9d3397e1d1a (patch)
treefb321d70f2a1a09ca35b5507bbf6b7f240ebc5bc
parent4dd18deab959adaf3f1f31b4e47349a657d273f0 (diff)
downloadastro-94eac19888398e91d436cf31867ba9d3397e1d1a.tar.gz
astro-94eac19888398e91d436cf31867ba9d3397e1d1a.tar.zst
astro-94eac19888398e91d436cf31867ba9d3397e1d1a.zip
Pre-release refactors (#289)
* refactor: expose `astro/components` as component entrypoint * refactor: remove `extensions` from all configs * test: fix snowpack tests * docs: update config doc
-rw-r--r--docs/config.md40
-rw-r--r--docs/markdown.md6
-rw-r--r--examples/astro-markdown/astro.config.mjs7
-rw-r--r--examples/astro-markdown/src/pages/index.astro2
-rw-r--r--examples/doc/astro.config.mjs6
-rw-r--r--examples/doc/src/pages/index.astro2
-rw-r--r--examples/portfolio/astro.config.mjs6
-rw-r--r--examples/remote-markdown/astro.config.mjs5
-rw-r--r--examples/remote-markdown/docs/dev.md48
-rw-r--r--examples/remote-markdown/package.json17
-rw-r--r--examples/remote-markdown/src/components/Yell.jsx10
-rw-r--r--examples/remote-markdown/src/layouts/main.astro14
-rw-r--r--examples/remote-markdown/src/pages/index.astro72
-rw-r--r--examples/remote-markdown/src/pages/test.astro6
-rw-r--r--examples/snowpack/astro.config.mjs15
-rw-r--r--packages/astro/components/index.js2
-rw-r--r--packages/astro/package.json1
-rw-r--r--packages/astro/src/frontend/500.astro2
-rw-r--r--packages/astro/test/fixtures/astro-expr/astro.config.mjs9
-rw-r--r--packages/astro/test/fixtures/astro-fallback/astro.config.mjs8
-rw-r--r--packages/astro/test/fixtures/astro-markdown/src/pages/code.astro2
-rw-r--r--packages/astro/test/fixtures/astro-markdown/src/pages/complex.astro2
-rw-r--r--packages/astro/test/fixtures/astro-markdown/src/pages/external.astro4
-rw-r--r--packages/astro/test/fixtures/astro-markdown/src/pages/post.astro2
-rw-r--r--packages/astro/test/fixtures/config-path/config/my-config.mjs8
-rw-r--r--packages/astro/test/fixtures/plain-markdown/astro.config.mjs6
26 files changed, 55 insertions, 247 deletions
diff --git a/docs/config.md b/docs/config.md
index 7474109cc..dbbe311a2 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -4,34 +4,24 @@ To configure Astro, add an `astro.config.mjs` file in the root of your project.
```js
export default {
- /** Where to resolve all URLs relative to. Useful if you have a monorepo project. */
- projectRoot: '.',
- /** Path to your site’s pages (routes) */
- pages: './src/pages',
- /** When running `astro build`, path to final static output */
- dist: './dist',
- /** A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing. */
- public: './public',
- /** Extension-specific handlings */
- extensions: {
- /** Set this to "preact" or "react" to determine what *.jsx files should load */
- '.jsx': 'react',
- },
- /** Options specific to `astro build` */
+ projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
+ pages: './src/pages', // Path to Astro components, pages, and data
+ dist: './dist', // When running `astro build`, path to final static output
+ public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
buildOptions: {
- /** Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs. */
- site: '',
- /** Generate sitemap (set to "false" to disable) */
- sitemap: true,
+ // site: '', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
+ sitemap: true, // Generate sitemap (set to "false" to disable)
},
- /** Options for the development server run with `astro dev`. */
devOptions: {
- /** The port to run the dev server on. */
- port: 3000,
- /** Path to tailwind.config.js if used, e.g. './tailwind.config.js' */
- tailwindConfig: undefined,
+ port: 3000, // The port to run the dev server on.
+ // tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
},
- /** default array of rendering packages inserted into runtime */
- renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'],
+ // component renderers which are enabled by default
+ renderers: [
+ '@astrojs/renderer-svelte',
+ '@astrojs/renderer-vue',
+ '@astrojs/renderer-react',
+ '@astrojs/renderer-preact'
+ ],
};
```
diff --git a/docs/markdown.md b/docs/markdown.md
index c20124096..822efb1ef 100644
--- a/docs/markdown.md
+++ b/docs/markdown.md
@@ -58,7 +58,7 @@ Astro exposes a special `Markdown` component for `.astro` files which enables ma
---
// For now, this import _must_ be named "Markdown" and _must not_ be wrapped with a custom component
// We're working on easing these restrictions!
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Layout from '../layouts/main.astro';
import MyFancyCodePreview from '../components/MyFancyCodePreview.tsx';
@@ -101,7 +101,7 @@ If you have Markdown in a remote source, you may pass it directly to the Markdow
```jsx
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpack/main/README.md').then(res => res.text());
---
@@ -115,7 +115,7 @@ Some times you might want to combine dynamic markdown with static markdown. You
```jsx
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpack/main/README.md').then(res => res.text());
---
diff --git a/examples/astro-markdown/astro.config.mjs b/examples/astro-markdown/astro.config.mjs
deleted file mode 100644
index a66babaf3..000000000
--- a/examples/astro-markdown/astro.config.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-export default {
- extensions: {
- '.jsx': 'react',
- '.tsx': 'preact',
- },
- public: './public'
-};
diff --git a/examples/astro-markdown/src/pages/index.astro b/examples/astro-markdown/src/pages/index.astro
index b46f3698f..666e0557f 100644
--- a/examples/astro-markdown/src/pages/index.astro
+++ b/examples/astro-markdown/src/pages/index.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Layout from '../layouts/main.astro';
import ReactCounter from '../components/ReactCounter.jsx';
import PreactCounter from '../components/PreactCounter.tsx';
diff --git a/examples/doc/astro.config.mjs b/examples/doc/astro.config.mjs
index 9ba6c58c9..d97e2804d 100644
--- a/examples/doc/astro.config.mjs
+++ b/examples/doc/astro.config.mjs
@@ -1,5 +1,5 @@
export default {
- extensions: {
- '.tsx': 'preact'
- }
+ renderers: [
+ '@astrojs/renderer-preact'
+ ]
};
diff --git a/examples/doc/src/pages/index.astro b/examples/doc/src/pages/index.astro
index fe00e15a8..75ca0da4f 100644
--- a/examples/doc/src/pages/index.astro
+++ b/examples/doc/src/pages/index.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Layout from '../layouts/Main.astro';
---
diff --git a/examples/portfolio/astro.config.mjs b/examples/portfolio/astro.config.mjs
index f50751cfd..d97e2804d 100644
--- a/examples/portfolio/astro.config.mjs
+++ b/examples/portfolio/astro.config.mjs
@@ -1,5 +1,5 @@
export default {
- extensions: {
- '.jsx': 'preact',
- },
+ renderers: [
+ '@astrojs/renderer-preact'
+ ]
};
diff --git a/examples/remote-markdown/astro.config.mjs b/examples/remote-markdown/astro.config.mjs
deleted file mode 100644
index c7bfe91b0..000000000
--- a/examples/remote-markdown/astro.config.mjs
+++ /dev/null
@@ -1,5 +0,0 @@
-export default {
- extensions: {
- '.jsx': 'preact'
- }
-}
diff --git a/examples/remote-markdown/docs/dev.md b/examples/remote-markdown/docs/dev.md
deleted file mode 100644
index d9223cbbd..000000000
--- a/examples/remote-markdown/docs/dev.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Development Server
-
-The development server comes as part of the Astro CLI. Start the server with:
-
-```shell
-astro dev
-```
-
-In your project root. You can specify an alternative
-
-## Special routes
-
-The dev server will serve the following special routes:
-
-### /400
-
-This is a custom **400** status code page. You can add this route by adding a page component to your `src/pages` folder:
-
-```
-├── src/
-│ ├── components/
-│ └── pages/
-│ └── 400.astro
-```
-
-For any URL you visit that doesn't have a corresponding page, the `400.astro` file will be used.
-
-### /500
-
-This is a custom **500** status code page. You can add this route by adding a page component to your `src/pages` folder:
-
-```astro
-├── src/ │ ├── components/ │ └── pages/ │ └── 500.astro
-```
-
-This page is used any time an error occurs in the dev server.
-
-The 500 page will receive an `error` query parameter which you can access with:
-
-```
----
-const error = Astro.request.url.searchParams.get('error');
----
-
-<strong>{error}</strong>
-```
-
-A default error page is included with Astro so you will get pretty error messages even without adding a custom 500 page.
diff --git a/examples/remote-markdown/package.json b/examples/remote-markdown/package.json
deleted file mode 100644
index 1c0524bf1..000000000
--- a/examples/remote-markdown/package.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "@example/remote-markdown",
- "version": "0.0.1",
- "private": true,
- "scripts": {
- "start": "astro dev",
- "build": "astro build",
- "astro-dev": "nodemon --delay 0.5 -w ../../packages/astro/dist -x '../../packages/astro/astro.mjs dev'"
- },
- "devDependencies": {
- "astro": "0.12.0-next.1",
- "nodemon": "^2.0.7"
- },
- "snowpack": {
- "workspaceRoot": "../.."
- }
-}
diff --git a/examples/remote-markdown/src/components/Yell.jsx b/examples/remote-markdown/src/components/Yell.jsx
deleted file mode 100644
index 366d88a95..000000000
--- a/examples/remote-markdown/src/components/Yell.jsx
+++ /dev/null
@@ -1,10 +0,0 @@
-import { h, Fragment } from 'preact';
-
-export default function Yell({ children }) {
- return (
- children
- .filter((v) => typeof v === 'string')
- .join('')
- .toUpperCase() + '!'
- );
-}
diff --git a/examples/remote-markdown/src/layouts/main.astro b/examples/remote-markdown/src/layouts/main.astro
deleted file mode 100644
index 37fcc0ee7..000000000
--- a/examples/remote-markdown/src/layouts/main.astro
+++ /dev/null
@@ -1,14 +0,0 @@
----
-export let content;
----
-
-<html>
- <head>
- <title>{content.title}</title>
- </head>
-
- <body>
- <slot />
- <pre>{JSON.stringify(content)}</pre>
- </body>
-</html>
diff --git a/examples/remote-markdown/src/pages/index.astro b/examples/remote-markdown/src/pages/index.astro
deleted file mode 100644
index 402780065..000000000
--- a/examples/remote-markdown/src/pages/index.astro
+++ /dev/null
@@ -1,72 +0,0 @@
----
-import Markdown from 'astro/components/Markdown.astro';
-import Yell from '../components/Yell.jsx';
-const title = 'INTERPOLATED';
-const quietTest = 'interpolated';
-const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpack/main/README.md').then(res => res.text());
----
-
-<!-- Basic -->
-<Markdown>
-# Hello world!
-</Markdown>
-
- <!-- Indented -->
- <Markdown>
- # Hello indent!
- </Markdown>
-
-<!-- Interpolation -->
-<Markdown>
-# Hello {title}!
-</Markdown>
-
-
- <!-- Can I break this? -->
- <Markdown>
- # I cannot!
-
- <div>
- # ahhhh
- </div>
-
- <Yell>{quietTest}</Yell>
-
- <strong>Dope</strong>
-
- `nice`
-
- ```
- plain fence
- ```
-
- ```html
- don't <div>me</div> bro
- ```
-
- ```js
- Astro.fetchContent()
- ```
-
- ### cool stuff?
- ```astro
- {'can\'t interpolate'}
- {}
- {title}
-
- Do I break? <Markdown> </Markdown>
- ```
- </Markdown>
-
-<!-- external content -->
-<Markdown>{content}</Markdown>
-
-<!-- external with newlines -->
-<Markdown>
- {content}
-</Markdown>
-
- <!-- external with indentation -->
- <Markdown>
- {content}
- </Markdown>
diff --git a/examples/remote-markdown/src/pages/test.astro b/examples/remote-markdown/src/pages/test.astro
deleted file mode 100644
index d0a050f35..000000000
--- a/examples/remote-markdown/src/pages/test.astro
+++ /dev/null
@@ -1,6 +0,0 @@
----
-import Markdown from 'astro/components/Markdown.astro';
-const content = await fetch('https://raw.githubusercontent.com/snowpackjs/snowpack/main/README.md').then(res => res.text());
----
-
-<Markdown content={content} />
diff --git a/examples/snowpack/astro.config.mjs b/examples/snowpack/astro.config.mjs
index eedfc34db..15bc31b47 100644
--- a/examples/snowpack/astro.config.mjs
+++ b/examples/snowpack/astro.config.mjs
@@ -3,14 +3,9 @@ export default {
pages: './src/pages',
dist: './dist',
public: './public',
- extensions: {
- '.jsx': 'preact',
- },
- snowpack: {
- optimize: {
- bundle: false,
- minify: true,
- target: 'es2018',
- },
- },
+ renderers: [
+ '@astrojs/renderer-vue',
+ '@astrojs/renderer-svelte',
+ '@astrojs/renderer-preact'
+ ]
};
diff --git a/packages/astro/components/index.js b/packages/astro/components/index.js
new file mode 100644
index 000000000..a6673415e
--- /dev/null
+++ b/packages/astro/components/index.js
@@ -0,0 +1,2 @@
+export { default as Markdown } from './Markdown.astro';
+export { default as Prism } from './Prism.astro';
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 237f72a8d..36266a05f 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -9,6 +9,7 @@
".": "./astro.mjs",
"./package.json": "./package.json",
"./snowpack-plugin": "./snowpack-plugin.cjs",
+ "./components": "./components/index.js",
"./components/*": "./components/*",
"./runtime/svelte": "./dist/frontend/runtime/svelte.js",
"./dist/frontend/markdown.js": "./dist/frontend/markdown.js"
diff --git a/packages/astro/src/frontend/500.astro b/packages/astro/src/frontend/500.astro
index 01fab8bea..4ffd7ac88 100644
--- a/packages/astro/src/frontend/500.astro
+++ b/packages/astro/src/frontend/500.astro
@@ -1,5 +1,5 @@
---
-import Prism from 'astro/components/Prism.astro';
+import { Prism } from 'astro/components';
let title = 'Uh oh...';
const error = Astro.request.url.searchParams.get('error');
diff --git a/packages/astro/test/fixtures/astro-expr/astro.config.mjs b/packages/astro/test/fixtures/astro-expr/astro.config.mjs
index 80d0860c3..6c6bb575d 100644
--- a/packages/astro/test/fixtures/astro-expr/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-expr/astro.config.mjs
@@ -1,6 +1,5 @@
-
export default {
- extensions: {
- '.jsx': 'preact'
- }
-} \ No newline at end of file
+ renderers: [
+ '@astrojs/renderer-preact'
+ ]
+}
diff --git a/packages/astro/test/fixtures/astro-fallback/astro.config.mjs b/packages/astro/test/fixtures/astro-fallback/astro.config.mjs
index f50751cfd..6c6bb575d 100644
--- a/packages/astro/test/fixtures/astro-fallback/astro.config.mjs
+++ b/packages/astro/test/fixtures/astro-fallback/astro.config.mjs
@@ -1,5 +1,5 @@
export default {
- extensions: {
- '.jsx': 'preact',
- },
-};
+ renderers: [
+ '@astrojs/renderer-preact'
+ ]
+}
diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/code.astro b/packages/astro/test/fixtures/astro-markdown/src/pages/code.astro
index 16a1158c9..19aa90e18 100644
--- a/packages/astro/test/fixtures/astro-markdown/src/pages/code.astro
+++ b/packages/astro/test/fixtures/astro-markdown/src/pages/code.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
export const title = 'My Blog Post';
export const description = 'This is a post about some stuff.';
---
diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/complex.astro b/packages/astro/test/fixtures/astro-markdown/src/pages/complex.astro
index aa9a872eb..4d470f48d 100644
--- a/packages/astro/test/fixtures/astro-markdown/src/pages/complex.astro
+++ b/packages/astro/test/fixtures/astro-markdown/src/pages/complex.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Layout from '../layouts/content.astro';
import Hello from '../components/Hello.jsx';
import Counter from '../components/Counter.jsx';
diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/external.astro b/packages/astro/test/fixtures/astro-markdown/src/pages/external.astro
index a39209d4a..0b7e5911a 100644
--- a/packages/astro/test/fixtures/astro-markdown/src/pages/external.astro
+++ b/packages/astro/test/fixtures/astro-markdown/src/pages/external.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Hello from '../components/Hello.jsx';
const outer = `# Outer`;
@@ -12,4 +12,4 @@ const inner = `## Inner`;
# Nested
<Markdown content={inner} />
-</Markdown> \ No newline at end of file
+</Markdown>
diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/post.astro b/packages/astro/test/fixtures/astro-markdown/src/pages/post.astro
index 05e740c04..b8cffd8c4 100644
--- a/packages/astro/test/fixtures/astro-markdown/src/pages/post.astro
+++ b/packages/astro/test/fixtures/astro-markdown/src/pages/post.astro
@@ -1,5 +1,5 @@
---
-import Markdown from 'astro/components/Markdown.astro';
+import { Markdown } from 'astro/components';
import Layout from '../layouts/content.astro';
import Example from '../components/Example.jsx';
diff --git a/packages/astro/test/fixtures/config-path/config/my-config.mjs b/packages/astro/test/fixtures/config-path/config/my-config.mjs
index f50751cfd..6c6bb575d 100644
--- a/packages/astro/test/fixtures/config-path/config/my-config.mjs
+++ b/packages/astro/test/fixtures/config-path/config/my-config.mjs
@@ -1,5 +1,5 @@
export default {
- extensions: {
- '.jsx': 'preact',
- },
-};
+ renderers: [
+ '@astrojs/renderer-preact'
+ ]
+}
diff --git a/packages/astro/test/fixtures/plain-markdown/astro.config.mjs b/packages/astro/test/fixtures/plain-markdown/astro.config.mjs
index c8631c503..d940a67c9 100644
--- a/packages/astro/test/fixtures/plain-markdown/astro.config.mjs
+++ b/packages/astro/test/fixtures/plain-markdown/astro.config.mjs
@@ -1,7 +1,7 @@
export default {
- extensions: {
- '.jsx': 'preact',
- },
+ renderers: [
+ '@astrojs/renderer-preact'
+ ],
buildOptions: {
sitemap: false,
},