Skip to content

Commit

Permalink
ci: update integration docs (#1926)
Browse files Browse the repository at this point in the history
Co-authored-by: delucis <delucis@users.noreply.github.com>
  • Loading branch information
astrobot-houston and delucis authored Oct 27, 2022
1 parent 338d610 commit 6ce3415
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/alpinejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ See [CHANGELOG.md](https://github.com/withastro/astro/tree/main/packages/integra

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
22 changes: 18 additions & 4 deletions src/pages/en/guides/integrations-guide/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,28 @@ $ pnpm install wrangler --save-dev

It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`.This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings).

## Access to the Cloudflare runtime

You can access all the Cloudflare bindings and environment variables from Astro components and API routes through the adapter API.

```js
import { getRuntime } from "@astrojs/cloudflare/runtime";

getRuntime(Astro.request);
```

Depending on your adapter mode (advanced = worker, directory = pages), the runtime object will look a little different due to differences in the Cloudflare API.

## Streams

Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag.
Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages Functions require enabling a flag to support Streams.

In order to work around this:
To do this:

* install the `"web-streams-polyfill"` package
* add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component.
* go to the Cloudflare Pages project
* click on Settings in the top bar, then Functions in the sidebar
* scroll down to Compatibility Flags, click Configure Production Compatibility Flags, and add `streams_enable_constructors`
* do this for both the Production Compatibility Flags and Preview Compatibility Flags

## Environment Variables

Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/deno.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Next, Update your `preview` script in `package.json` with the change below.
## Usage
After [performing a build](/en/guides/deploy/) there will be a `dist/server/entry.mjs` module. You can start a server by importing this module in your Deno app:
After [performing a build](/en/guides/deploy/#building-your-site-locally) there will be a `dist/server/entry.mjs` module. You can start a server by importing this module in your Deno app:
```js
import './dist/entry.mjs';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/lit.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
44 changes: 23 additions & 21 deletions src/pages/en/guides/integrations-guide/mdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Finally, restart the dev server.

## Usage

You can [add MDX pages to your project](/en/guides/markdown-content/) by adding `.mdx` files within your `src/pages/` directory.
You can [add MDX pages to your project](/en/guides/markdown-content/#markdown-and-mdx-pages) by adding `.mdx` files within your `src/pages/` directory.

### Components

Expand All @@ -93,7 +93,7 @@ To use components in your MDX pages in Astro, head to our [UI framework document
* 💧 client-side hydration options, and
* 🤝 opportunities to mix and nest frameworks together

[**Client Directives**](/en/reference/directives-reference/) are still required in `.mdx` files.
[**Client Directives**](/en/reference/directives-reference/#client-directives) are still required in `.mdx` files.

> **Note**: `.mdx` files adhere to strict JSX syntax rather than Astro's HTML-like syntax.
Expand All @@ -109,7 +109,7 @@ export const title = 'My first MDX post'
# {title}
```

This `title` will be accessible from `import` and [glob](/en/reference/api-reference/) statements as well:
This `title` will be accessible from `import` and [glob](/en/reference/api-reference/#astroglob) statements as well:

```astro
---
Expand All @@ -124,7 +124,7 @@ See [the official "how MDX works" guide](https://mdxjs.com/docs/using-mdx/#how-m

### Exported properties

Alongside your [MDX variable exports](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#variables), we generate a few helpful exports as well. These are accessible when importing an MDX file via `import` statements or [`Astro.glob`](/en/reference/api-reference/).
Alongside your [MDX variable exports](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#variables), we generate a few helpful exports as well. These are accessible when importing an MDX file via `import` statements or [`Astro.glob`](/en/reference/api-reference/#astroglob).

#### `file`

Expand Down Expand Up @@ -155,7 +155,7 @@ publishDate: '21 September 2022'
# {frontmatter.title}
```

Now, this `title` and `publishDate` will be accessible from `import` and [glob](/en/reference/api-reference/) statements via the `frontmatter` property. This matches the behavior of [plain markdown in Astro](/en/reference/api-reference/) as well!
Now, this `title` and `publishDate` will be accessible from `import` and [glob](/en/reference/api-reference/#astroglob) statements via the `frontmatter` property. This matches the behavior of [plain markdown in Astro](/en/reference/api-reference/#markdown-files) as well!

```astro
---
Expand All @@ -173,7 +173,7 @@ const posts = await Astro.glob('./*.mdx');

### Inject frontmatter via remark or rehype plugins

You may want to inject frontmatter properties across all of your MDX files. By using a [remark](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#remarkPlugins) or [rehype](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#remarkplugins) plugin, you can generate these properties based on a file’s contents.
You may want to inject frontmatter properties across all of your MDX files. By using a [remark](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#remarkplugins) or [rehype](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#rehypeplugins) plugin, you can generate these properties based on a file’s contents.

You can append to the `data.astro.frontmatter` property from your plugin’s `file` argument like so:

Expand Down Expand Up @@ -203,11 +203,11 @@ export default {
};
```

…every MDX file will have `customProperty` in its frontmatter! See [our Markdown documentation](/en/guides/markdown-content/) for more usage instructions and a [reading time plugin example](/en/guides/markdown-content/).
…every MDX file will have `customProperty` in its frontmatter! See [our Markdown documentation](/en/guides/markdown-content/#injecting-frontmatter) for more usage instructions and a [reading time plugin example](/en/guides/markdown-content/#example-calculate-reading-time).

### Layouts

Layouts can be applied [in the same way as standard Astro Markdown](/en/guides/markdown-content/). You can add a `layout` to [your frontmatter](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#frontmatter) like so:
Layouts can be applied [in the same way as standard Astro Markdown](/en/guides/markdown-content/#frontmatter-layout). You can add a `layout` to [your frontmatter](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#frontmatter) like so:

```yaml
---
Expand All @@ -216,7 +216,7 @@ title: 'My Blog Post'
---
```

Then, you can retrieve all other frontmatter properties from your layout via the `frontmatter` property, and render your MDX using the default [`<slot />`](/en/core-concepts/astro-components/). See [layout props](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#layout-props) for a complete list of props available.
Then, you can retrieve all other frontmatter properties from your layout via the `frontmatter` property, and render your MDX using the default [`<slot />`](/en/core-concepts/astro-components/#slots). See [layout props](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#layout-props) for a complete list of props available.

```astro
---
Expand Down Expand Up @@ -355,20 +355,22 @@ Now, writing the standard Markdown blockquote syntax (`>`) will use your custom

#### Custom components with imported `mdx`

When rendering imported MDX content, custom components can also be passed via the `components` prop:
When rendering imported MDX content, custom components can be passed via the `components` prop.

```astro title="src/pages/page.astro" "components={{ h1: Heading }}"
Note: An MDX file's exported components will *not* be used unless you manually import and pass them via the `components` property. See the example below:

```astro title="src/pages/page.astro" "components={{...components, h1: Heading }}"
---
import Content from '../content.mdx';
import { Content, components } from '../content.mdx';
import Heading from '../Heading.astro';
---
<Content components={{ h1: Heading }} />
<Content components={{...components, h1: Heading }} />
```

### Syntax highlighting

The MDX integration respects [your project's `markdown.syntaxHighlight` configuration](/en/guides/markdown-content/).
The MDX integration respects [your project's `markdown.syntaxHighlight` configuration](/en/guides/markdown-content/#syntax-highlighting).

We will highlight your code blocks with [Shiki](https://github.com/shikijs/shiki) by default. You can customize this highlighter using the `markdown.shikiConfig` option in your `astro.config`. For example, you can apply a different built-in theme like so:

Expand All @@ -384,7 +386,7 @@ export default {
}
```

Visit [our Shiki configuration docs](/en/guides/markdown-content/) for more on using Shiki with Astro.
Visit [our Shiki configuration docs](/en/guides/markdown-content/#shiki-configuration) for more on using Shiki with Astro.

#### Switch to Prism

Expand All @@ -400,7 +402,7 @@ export default {
}
```

This applies a minimal Prism renderer with added support for `astro` code blocks. Visit [our "Prism configuration" docs](/en/guides/markdown-content/) for more on using Prism with Astro.
This applies a minimal Prism renderer with added support for `astro` code blocks. Visit [our "Prism configuration" docs](/en/guides/markdown-content/#prism-configuration) for more on using Prism with Astro.

#### Switch to a custom syntax highlighter

Expand All @@ -425,7 +427,7 @@ export default {
[Remark plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md) allow you to extend your Markdown with new capabilities. This includes [auto-generating a table of contents](https://github.com/remarkjs/remark-toc), [applying accessible emoji labels](https://github.com/florianeckerstorfer/remark-a11y-emoji), and more. We encourage you to browse [awesome-remark](https://github.com/remarkjs/awesome-remark) for a full curated list!
This example applies the [`remark-toc`](https://github.com/remarkjs/remark-toc) plugin to `.mdx` files. To customize plugin inheritance from your Markdown config or Astro's defaults, [see the `extendPlugins` option](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#extendPlugins).
This example applies the [`remark-toc`](https://github.com/remarkjs/remark-toc) plugin to `.mdx` files. To customize plugin inheritance from your Markdown config or Astro's defaults, [see the `extendPlugins` option](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#extendplugins).
```js
// astro.config.mjs
Expand All @@ -444,7 +446,7 @@ export default {
We apply our own (non-removable) [`collect-headings`](https://github.com/withastro/astro/blob/main/packages/integrations/mdx/src/rehype-collect-headings.ts) plugin. This applies IDs to all headings (i.e. `h1 -> h6`) in your MDX files to [link to headings via anchor tags](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#linking_to_an_element_on_the_same_page).
This example applies the [`rehype-minify`](https://github.com/rehypejs/rehype-minify) plugin to `.mdx` files. To customize plugin inheritance from your Markdown config or Astro's defaults, [see the `extendPlugins` option](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#extendPlugins).
This example applies the [`rehype-minify`](https://github.com/rehypejs/rehype-minify) plugin to `.mdx` files. To customize plugin inheritance from your Markdown config or Astro's defaults, [see the `extendPlugins` option](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#extendplugins).
```js
// astro.config.mjs
Expand All @@ -465,7 +467,7 @@ export default {
#### `markdown` (default)
By default, Astro inherits all [remark](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#remarkPlugins) and [rehype](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#rehypePlugins) plugins from [the `markdown` option in your Astro config](/en/guides/markdown-content/). This also respects the [`markdown.extendDefaultPlugins`](/en/reference/configuration-reference/) option to extend Astro's defaults. Any additional plugins you apply in your MDX config will be applied *after* your configured Markdown plugins.
By default, Astro inherits all [remark](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#remarkplugins) and [rehype](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/#rehypeplugins) plugins from [the `markdown` option in your Astro config](/en/guides/markdown-content/#markdown-plugins). This also respects the [`markdown.extendDefaultPlugins`](/en/reference/configuration-reference/#markdownextenddefaultplugins) option to extend Astro's defaults. Any additional plugins you apply in your MDX config will be applied *after* your configured Markdown plugins.
This example applies [`remark-toc`](https://github.com/remarkjs/remark-toc) to Markdown *and* MDX, and [`rehype-minify`](https://github.com/rehypejs/rehype-minify) to MDX alone:
Expand All @@ -488,7 +490,7 @@ export default {
#### `astroDefaults`
You may *only* want to extend [Astro's default plugins](/en/reference/configuration-reference/) without inheriting your Markdown config. This example will apply the default [GitHub-Flavored Markdown](https://github.com/remarkjs/remark-gfm) and [Smartypants](https://github.com/silvenon/remark-smartypants) plugins alongside [`remark-toc`](https://github.com/remarkjs/remark-toc):
You may *only* want to extend [Astro's default plugins](/en/reference/configuration-reference/#markdownextenddefaultplugins) without inheriting your Markdown config. This example will apply the default [GitHub-Flavored Markdown](https://github.com/remarkjs/remark-gfm) and [Smartypants](https://github.com/silvenon/remark-smartypants) plugins alongside [`remark-toc`](https://github.com/remarkjs/remark-toc):
```js "extendPlugins: 'astroDefaults'"
// astro.config.mjs
Expand Down Expand Up @@ -549,4 +551,4 @@ See [CHANGELOG.md](https://github.com/withastro/astro/tree/main/packages/integra
[astro-integration]: /en/guides/integrations-guide/
[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Netlify has two serverless platforms, Netlify Functions and [Netlify's experimen
[Read the full deployment guide here.](/en/guides/deploy/netlify/)
After [performing a build](/en/guides/deploy/) the `netlify/` folder will contain [Netlify Functions](https://docs.netlify.com/functions/overview/) in the `netlify/functions/` folder.
After [performing a build](/en/guides/deploy/#building-your-site-locally) the `netlify/` folder will contain [Netlify Functions](https://docs.netlify.com/functions/overview/) in the `netlify/functions/` folder.
Now you can deploy. Install the [Netlify CLI](https://docs.netlify.com/cli/get-started/) and run:
Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Controls whether the adapter builds to `middleware` or `standalone` mode.
## Usage
First, [performing a build](/en/guides/deploy/). Depending on which `mode` selected (see above) follow the appropriate steps below:
First, [performing a build](/en/guides/deploy/#building-your-site-locally). Depending on which `mode` selected (see above) follow the appropriate steps below:
### Middleware
Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/partytown.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ This mirrors the [Partytown config object](https://partytown.builder.io/configur

Partytown ships with a `debug` mode; enable or disable it by passing `true` or `false` to `config.debug`. If [`debug` mode](https://partytown.builder.io/debugging) is enabled, it will output detailed logs to the browser console.

If this option isn't set, `debug` mode will be on by default in [dev](/en/reference/cli-reference/) or [preview](/en/reference/cli-reference/) mode.
If this option isn't set, `debug` mode will be on by default in [dev](/en/reference/cli-reference/#astro-dev) or [preview](/en/reference/cli-reference/#astro-preview) mode.

**`astro.config.mjs`**

Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/preact.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ See [CHANGELOG.md](https://github.com/withastro/astro/tree/main/packages/integra

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default defineConfig({

Note that unlike other configuration options, `site` is set in the root `defineConfig` object, rather than inside the `sitemap()` call.

Now, [build your site for production](/en/reference/cli-reference/) via the `astro build` command. You should find your sitemap under `dist/` for both `sitemap-index.xml` and `sitemap-0.xml`!
Now, [build your site for production](/en/reference/cli-reference/#astro-build) via the `astro build` command. You should find your sitemap under `dist/` for both `sitemap-index.xml` and `sitemap-0.xml`!

> **Warning**
> If you forget to add a `site`, you'll get a friendly warning when you build, and the `sitemap-index.xml` file won't be generated.
Expand Down
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/solid-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
2 changes: 1 addition & 1 deletion src/pages/en/guides/integrations-guide/svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components

## Options

Expand Down
4 changes: 2 additions & 2 deletions src/pages/en/guides/integrations-guide/tailwind.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default {
}
```

You can now [import your own `base.css` as a local stylesheet](/en/guides/styling/).
You can now [import your own `base.css` as a local stylesheet](/en/guides/styling/#import-a-local-stylesheet).

If you are using Vue, Svelte, or another component integration with Astro, `@apply` directives used in component `<style>`s may generate errors about your custom Tailwind class not existing and cause your builds to fail. [Instead of using `@layer` directives in a a global stylesheet](https://tailwindcss.com/docs/functions-and-directives#using-apply-with-per-component-css), define your custom styles by adding a plugin to your Tailwind config:

Expand Down Expand Up @@ -175,7 +175,7 @@ You can also check our [Astro Integration Documentation][astro-integration] for

[astro-integration]: /en/guides/integrations-guide/

[astro-ui-frameworks]: /en/core-concepts/framework-components/
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components

## Contributing

Expand Down
Loading

0 comments on commit 6ce3415

Please sign in to comment.