Skip to content

Commit 1baf0b0

Browse files
sarah11918ematipicoElianCodesalexanderniebuhr
authored
[docs] minimal integration READMEs (#9479)
Co-authored-by: Emanuele Stoppa <[email protected]> Co-authored-by: Elian <[email protected]> Co-authored-by: Alexander Niebuhr <[email protected]>
1 parent f9c4bbf commit 1baf0b0

File tree

15 files changed

+324
-2944
lines changed

15 files changed

+324
-2944
lines changed

.changeset/soft-sheep-glow.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@astrojs/alpinejs': patch
3+
'@astrojs/lit': patch
4+
'@astrojs/markdoc': patch
5+
'@astrojs/mdx': patch
6+
'@astrojs/node': patch
7+
'@astrojs/partytown': patch
8+
'@astrojs/preact': patch
9+
'@astrojs/react': patch
10+
'@astrojs/sitemap': patch
11+
'@astrojs/solid-js': patch
12+
'@astrojs/svelte': patch
13+
'@astrojs/tailwind': patch
14+
'@astrojs/vercel': patch
15+
'@astrojs/vue': patch
16+
---
17+
18+
Updates README

packages/integrations/alpinejs/README.md

Lines changed: 22 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,109 +2,37 @@
22

33
This **[Astro integration][astro-integration]** adds [Alpine.js](https://alpinejs.dev/) to your project so that you can use Alpine.js anywhere on your page.
44

5-
- <strong>[Installation](#installation)</strong>
6-
- <strong>[Usage](#usage)</strong>
7-
- <strong>[Configuration](#configuration)</strong>
8-
- <strong>[Examples](#examples)</strong>
9-
- <strong>[Troubleshooting](#troubleshooting)</strong>
10-
- <strong>[Contributing](#contributing)</strong>
11-
- <strong>[Changelog](#changelog)</strong>
5+
## Documentation
126

13-
## Installation
7+
Read the [`@astrojs/alpinejs` docs][docs]
148

15-
### Quick Install
9+
## Support
1610

17-
The `astro add` command-line tool automates the installation for you. Run one of the following commands in a new terminal window. (If you aren't sure which package manager you're using, run the first command.) Then, follow the prompts, and type "y" in the terminal (meaning "yes") for each one.
11+
- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more!
1812

19-
```sh
20-
# Using NPM
21-
npx astro add alpinejs
22-
# Using Yarn
23-
yarn astro add alpinejs
24-
# Using PNPM
25-
pnpm astro add alpinejs
26-
```
13+
- Check our [Astro Integration Documentation][astro-integration] for more on integrations.
2714

28-
If you run into any issues, [feel free to report them to us on GitHub](https://github.com/withastro/astro/issues) and try the manual installation steps below.
15+
- Submit bug reports and feature requests as [GitHub issues][issues].
2916

30-
### Manual Install
31-
32-
First, install the `@astrojs/alpinejs` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
33-
34-
```sh
35-
npm install @astrojs/alpinejs
36-
```
37-
38-
Most package managers will install associated peer dependencies as well. However, if you see a "Cannot find package 'alpinejs'" (or similar) warning when you start up Astro, you'll need to manually install Alpine.js yourself:
39-
40-
```sh
41-
npm install alpinejs @types/alpinejs
42-
```
43-
44-
Then, apply this integration to your `astro.config.*` file using the `integrations` property:
45-
46-
```diff lang="js" "alpine()"
47-
// astro.config.mjs
48-
import { defineConfig } from 'astro/config';
49-
+ import alpine from '@astrojs/alpinejs';
50-
51-
export default defineConfig({
52-
// ...
53-
integrations: [alpine()],
54-
// ^^^^^^^^
55-
});
56-
```
57-
58-
## Usage
59-
60-
Once the integration is installed, you can use [Alpine.js](https://alpinejs.dev/) directives and syntax inside any Astro component. The Alpine.js script is automatically added and enabled on every page of your website.
61-
62-
Check our [Astro Integration Documentation][astro-integration] for more on integrations.
63-
64-
## Limitations
65-
66-
The Alpine.js integration does not give you control over how the script is loaded or initialized. If you require this control, consider [installing and using Alpine.js manually](https://alpinejs.dev/essentials/installation). Astro supports all officially documented Alpine.js manual setup instructions, using `<script>` tags inside of an Astro component.
67-
68-
**It is not currently possible to [extend Alpine.js](https://alpinejs.dev/advanced/extending) when using this component.** If you need this feature, consider following [the manual Alpine.js setup](https://alpinejs.dev/essentials/installation) instead using an Astro script tag:
69-
70-
```astro
71-
---
72-
// src/pages/index.astro
73-
---
74-
75-
<!-- Example: Load AlpineJS on a single page. -->
76-
<script>
77-
import Alpine from 'alpinejs';
78-
79-
// Optional: Extend Alpine.js
80-
// Alpine.directive('foo', ...)
81-
82-
window.Alpine = Alpine;
83-
Alpine.start();
84-
</script>
85-
```
86-
87-
## Configuration
88-
89-
The Alpine.js integration does not support any custom configuration at this time.
90-
91-
## Examples
92-
93-
- The [Astro Alpine.js example](https://github.com/withastro/astro/tree/latest/examples/framework-alpine) shows how to use Alpine.js in an Astro project.
94-
95-
## Troubleshooting
96-
97-
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
17+
## Contributing
9818

99-
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
19+
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started:
10020

101-
## Contributing
21+
- [Contributor Manual][contributing]
22+
- [Code of Conduct][coc]
23+
- [Community Guide][community]
10224

103-
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
25+
## License
10426

105-
## Changelog
27+
MIT
10628

107-
See [CHANGELOG.md](CHANGELOG.md) for a history of changes to this integration.
29+
Copyright (c) 2023–present [Astro][astro]
10830

109-
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
110-
[astro-ui-frameworks]: https://docs.astro.build/en/core-concepts/framework-components/#using-framework-components
31+
[astro]: https://astro.build/
32+
[docs]: https://docs.astro.build/en/guides/integrations-guide/alpinejs/
33+
[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md
34+
[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md
35+
[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md
36+
[discord]: https://astro.build/chat/
37+
[issues]: https://github.com/withastro/astro/issues
38+
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/

packages/integrations/lit/README.md

Lines changed: 22 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -2,156 +2,37 @@
22

33
This **[Astro integration][astro-integration]** enables server-side rendering and client-side hydration for your [Lit](https://lit.dev/) custom elements.
44

5-
## Installation
5+
## Documentation
66

7-
There are two ways to add integrations to your project. Let's try the most convenient option first!
7+
Read the [`@astrojs/lit` docs][docs]
88

9-
### `astro add` command
9+
## Support
1010

11-
Astro includes a CLI tool for adding first party integrations: `astro add`. This command will:
11+
- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more!
1212

13-
1. (Optionally) Install all necessary dependencies and peer dependencies
14-
2. (Also optionally) Update your `astro.config.*` file to apply this integration
13+
- Check our [Astro Integration Documentation][astro-integration] for more on integrations.
1514

16-
To install `@astrojs/lit`, run the following from your project directory and follow the prompts:
15+
- Submit bug reports and feature requests as [GitHub issues][issues].
1716

18-
```sh
19-
# Using NPM
20-
npx astro add lit
21-
# Using Yarn
22-
yarn astro add lit
23-
# Using PNPM
24-
pnpm astro add lit
25-
```
26-
27-
If you run into any issues, [feel free to report them to us on GitHub](https://github.com/withastro/astro/issues) and try the manual installation steps below.
28-
29-
### Install dependencies manually
30-
31-
First, install the `@astrojs/lit` integration like so:
32-
33-
```sh
34-
npm install @astrojs/lit
35-
```
36-
37-
Most package managers will install associated peer dependencies as well. Still, if you see a "Cannot find package 'lit'" (or similar) warning when you start up Astro, you'll need to install `lit` and `@webcomponents/template-shadowroot`:
38-
39-
```sh
40-
npm install lit @webcomponents/template-shadowroot
41-
```
42-
43-
Now, apply this integration to your `astro.config.*` file using the `integrations` property:
44-
45-
```diff lang="js" "lit()"
46-
// astro.config.mjs
47-
import { defineConfig } from 'astro/config';
48-
+ import lit from '@astrojs/lit';
49-
50-
export default defineConfig({
51-
// ...
52-
integrations: [lit()],
53-
// ^^^^^
54-
});
55-
```
56-
57-
## Getting started
58-
59-
To use your first Lit component in Astro, head to our [UI framework documentation][astro-ui-frameworks]. This explains:
60-
61-
- 📦 how framework components are loaded,
62-
- 💧 client-side hydration options, and
63-
- 🤝 opportunities to mix and nest frameworks together
64-
65-
Writing and importing a Lit component in Astro looks like this:
66-
67-
```js
68-
// src/components/my-element.js
69-
import { LitElement, html } from 'lit';
70-
71-
export class MyElement extends LitElement {
72-
render() {
73-
return html` <p>Hello world! From my-element</p> `;
74-
}
75-
}
76-
77-
customElements.define('my-element', MyElement);
78-
```
79-
80-
Now, the component is ready to be imported via the Astro frontmatter:
81-
82-
```astro
83-
---
84-
// src/pages/index.astro
85-
import { MyElement } from '../components/my-element.js';
86-
---
87-
88-
<MyElement />
89-
```
90-
91-
> Note that Lit requires browser globals such as `HTMLElement` and `customElements` to be present. For this reason the Lit renderer shims the server with these globals so Lit can run. You _might_ run into libraries that work incorrectly because of this.
92-
93-
### Polyfills & Hydration
94-
95-
The renderer automatically handles adding appropriate polyfills for support in browsers that don't have Declarative Shadow DOM. The polyfill is about _1.5kB_. If the browser does support Declarative Shadow DOM then less than 250 bytes are loaded (to feature detect support).
96-
97-
Hydration is also handled automatically. You can use the same hydration directives such as `client:load`, `client:idle` and `client:visible` as you can with other libraries that Astro supports.
98-
99-
```astro
100-
---
101-
import { MyElement } from '../components/my-element.js';
102-
---
103-
104-
<MyElement client:visible />
105-
```
106-
107-
The above will only load the element's JavaScript when the user has scrolled it into view. Since it is server rendered they will not see any jank; it will load and hydrate transparently.
108-
109-
## Troubleshooting
110-
111-
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
112-
113-
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
114-
115-
Common issues are listed below:
116-
117-
### Browser globals
118-
119-
The Lit integration's SSR works by adding a few browser global properties to the global environment. Some of the properties it adds includes `window`, `document`, and `location`.
120-
121-
These globals _can_ interfere with other libraries that might use the existence of these variables to detect that they are running in the browser, when they are actually running in the server. This can cause bugs with these libraries.
122-
123-
Because of this, the Lit integration might not be compatible with these types of libraries. One thing that can help is changing the order of integrations when Lit is interfering with other integrations:
124-
125-
```diff lang="js"
126-
// astro.config.mjs
127-
import { defineConfig } from 'astro/config';
128-
import vue from '@astrojs/vue';
129-
import lit from '@astrojs/lit';
130-
131-
export default defineConfig({
132-
- integrations: [vue(), lit()]
133-
+ integrations: [lit(), vue()]
134-
});
135-
```
136-
137-
The correct order might be different depending on the underlying cause of the problem. This is not guaranteed to fix every issue however, and some libraries cannot be used if you are using the Lit integration because of this.
138-
139-
### Strict package managers
140-
141-
When using a [strict package manager](https://pnpm.io/pnpm-vs-npm#npms-flat-tree) like `pnpm`, you may get an error such as `ReferenceError: module is not defined` when running your site. To fix this, hoist Lit dependencies with an `.npmrc` file:
17+
## Contributing
14218

143-
```ini
144-
# .npmrc
145-
public-hoist-pattern[]=*lit*
146-
```
19+
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started:
14720

148-
### Limitations
21+
- [Contributor Manual][contributing]
22+
- [Code of Conduct][coc]
23+
- [Community Guide][community]
14924

150-
The Lit integration is powered by `@lit-labs/ssr` which has some limitations. See their [limitations documentation](https://www.npmjs.com/package/@lit-labs/ssr#user-content-notes-and-limitations) to learn more.
25+
## License
15126

152-
## Contributing
27+
MIT
15328

154-
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
29+
Copyright (c) 2023–present [Astro][astro]
15530

156-
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
157-
[astro-ui-frameworks]: https://docs.astro.build/en/core-concepts/framework-components/#using-framework-components
31+
[astro]: https://astro.build/
32+
[docs]: https://docs.astro.build/en/guides/integrations-guide/lit/
33+
[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md
34+
[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md
35+
[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md
36+
[discord]: https://astro.build/chat/
37+
[issues]: https://github.com/withastro/astro/issues
38+
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/

0 commit comments

Comments
 (0)