Skip to content

Commit

Permalink
Pre-release refactors (#289)
Browse files Browse the repository at this point in the history
* refactor: expose `astro/components` as component entrypoint

* refactor: remove `extensions` from all configs

* test: fix snowpack tests

* docs: update config doc
  • Loading branch information
natemoo-re authored Jun 2, 2021
1 parent 4dd18de commit 94eac19
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 247 deletions.
40 changes: 15 additions & 25 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
],
};
```
6 changes: 3 additions & 3 deletions docs/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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());
---
Expand All @@ -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());
---
Expand Down
7 changes: 0 additions & 7 deletions examples/astro-markdown/astro.config.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/astro-markdown/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 3 additions & 3 deletions examples/doc/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
extensions: {
'.tsx': 'preact'
}
renderers: [
'@astrojs/renderer-preact'
]
};
2 changes: 1 addition & 1 deletion examples/doc/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import Markdown from 'astro/components/Markdown.astro';
import { Markdown } from 'astro/components';
import Layout from '../layouts/Main.astro';
---

Expand Down
6 changes: 3 additions & 3 deletions examples/portfolio/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
extensions: {
'.jsx': 'preact',
},
renderers: [
'@astrojs/renderer-preact'
]
};
5 changes: 0 additions & 5 deletions examples/remote-markdown/astro.config.mjs

This file was deleted.

48 changes: 0 additions & 48 deletions examples/remote-markdown/docs/dev.md

This file was deleted.

17 changes: 0 additions & 17 deletions examples/remote-markdown/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions examples/remote-markdown/src/components/Yell.jsx

This file was deleted.

14 changes: 0 additions & 14 deletions examples/remote-markdown/src/layouts/main.astro

This file was deleted.

72 changes: 0 additions & 72 deletions examples/remote-markdown/src/pages/index.astro

This file was deleted.

6 changes: 0 additions & 6 deletions examples/remote-markdown/src/pages/test.astro

This file was deleted.

15 changes: 5 additions & 10 deletions examples/snowpack/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
};
2 changes: 2 additions & 0 deletions packages/astro/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Markdown } from './Markdown.astro';
export { default as Prism } from './Prism.astro';
1 change: 1 addition & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/frontend/500.astro
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
9 changes: 4 additions & 5 deletions packages/astro/test/fixtures/astro-expr/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export default {
extensions: {
'.jsx': 'preact'
}
}
renderers: [
'@astrojs/renderer-preact'
]
}
8 changes: 4 additions & 4 deletions packages/astro/test/fixtures/astro-fallback/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
extensions: {
'.jsx': 'preact',
},
};
renderers: [
'@astrojs/renderer-preact'
]
}
Original file line number Diff line number Diff line change
@@ -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.';
---
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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`;
Expand All @@ -12,4 +12,4 @@ const inner = `## Inner`;
# Nested

<Markdown content={inner} />
</Markdown>
</Markdown>
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Loading

0 comments on commit 94eac19

Please sign in to comment.