Skip to content

Commit c8ef46f

Browse files
authored
Merge branch 'main' into vt-forms
2 parents 83d315a + 2f43346 commit c8ef46f

80 files changed

Lines changed: 6896 additions & 233 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"astro-auto-import": "^0.3.1",
4848
"astro-eslint-parser": "^0.9.2",
4949
"astro-expressive-code": "^0.20.0",
50-
"astro-og-canvas": "^0.2.1",
50+
"astro-og-canvas": "^0.3.0",
5151
"bcp-47-normalize": "^2.1.0",
5252
"canvaskit-wasm": "^0.37.0",
5353
"dedent-js": "^1.0.1",

pnpm-lock.yaml

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/en/core-concepts/astro-components.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@ Named slots can also be passed to [UI framework components](/en/core-concepts/fr
258258
:::
259259

260260

261+
:::note
262+
An astro slot name can not be dynamically generated, such as within a map function. If this feature is needed within UI framework components, it might be best to generate these dynamic slots within the framework itself.
263+
:::
264+
265+
261266
### Fallback Content for Slots
262267
Slots can also render **fallback content**. When there are no matching children passed to a slot, a `<slot />` element will render its own placeholder children.
263268

src/content/docs/en/guides/cms/tina-cms.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ To get started, you'll need an existing Astro project.
4949
{
5050
"scripts": {
5151
"dev": "astro dev",
52-
"dev": "tinacms dev -c 'astro dev'"
52+
"dev": "tinacms dev -c \"astro dev\""
5353
}
5454
}
5555
```
@@ -60,7 +60,7 @@ To get started, you'll need an existing Astro project.
6060
{
6161
"scripts": {
6262
"dev": "astro dev",
63-
"dev": "tinacms dev -c 'astro dev'"
63+
"dev": "tinacms dev -c \"astro dev\""
6464
}
6565
}
6666
```
@@ -71,7 +71,7 @@ To get started, you'll need an existing Astro project.
7171
{
7272
"scripts": {
7373
"dev": "astro dev",
74-
"dev": "tinacms dev -c 'astro dev'"
74+
"dev": "tinacms dev -c \"astro dev\""
7575
}
7676
}
7777
```

src/content/docs/en/guides/deploy/gitlab.mdx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ Check out [the official GitLab Pages Astro example project](https://gitlab.com/p
3535
4. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content:
3636

3737
```yaml
38-
# The Docker image that will be used to build your app
39-
image: node:lts
40-
41-
before_script:
42-
- npm ci
43-
44-
pages:
45-
script:
46-
# Specify the steps involved to build your app here
47-
- npm run build
48-
49-
artifacts:
50-
paths:
51-
# The folder that contains the built files to be published.
52-
# This must be called "public".
53-
- public
54-
55-
only:
56-
# Trigger a new build and deploy only when there is a push to the
57-
# branch(es) below
58-
- main
38+
pages:
39+
# The Docker image that will be used to build your app
40+
image: node:lts
41+
42+
before_script:
43+
- npm ci
44+
45+
script:
46+
# Specify the steps involved to build your app here
47+
- npm run build
48+
49+
artifacts:
50+
paths:
51+
# The folder that contains the built files to be published.
52+
# This must be called "public".
53+
- public
54+
55+
only:
56+
# Trigger a new build and deploy only when there is a push to the
57+
# branch(es) below
58+
- main
5959
```

src/content/docs/en/guides/integrations-guide/prefetch.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import DontEditWarning from '~/components/DontEditWarning.astro';
2121

2222
<DontEditWarning/>
2323

24+
> NOTE: `@astrojs/prefetch` is deprecated. Use the `prefetch` feature in Astro 3.5 instead. Check out the [migration guide](/en/guides/prefetch/#migrating-from-astrojsprefetch).
25+
2426
## Why Prefetch?
2527

2628
Page load times play a big role in usability and overall enjoyment of a site. This integration brings the benefits of near-instant page navigations to your multi-page application (MPA) by prefetching page links when they are visible on screen.

src/content/docs/en/guides/markdown-content.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ I can link internally to [my conclusion](#conclusion) on the same page when writ
119119
I can use the URL `https://example.com/page-1/#introduction` to navigate directly to my Introduction on the page.
120120
```
121121

122+
Astro generates heading `id`s based on `github-slugger`. You can find more examples in [the github-slugger documentation](https://github.com/Flet/github-slugger#usage).
123+
122124
### Escaping special characters
123125

124126
Certain characters have a special meaning in Markdown and MDX. You may need to use a different syntax if you want to display them. To do this, you can use [HTML entities](https://developer.mozilla.org/en-US/docs/Glossary/Entity) for these characters instead.
@@ -589,6 +591,12 @@ export default defineConfig({
589591
// Choose from Shiki's built-in themes (or add your own)
590592
// https://github.com/shikijs/shiki/blob/main/docs/themes.md
591593
theme: 'dracula',
594+
// Alternatively, provide multiple themes
595+
// https://github.com/antfu/shikiji#lightdark-dual-themes
596+
experimentalThemes: {
597+
light: 'github-light',
598+
dark: 'github-dark',
599+
},
592600
// Add custom languages
593601
// Note: Shiki has countless langs built-in, including .astro!
594602
// https://github.com/shikijs/shiki/blob/main/docs/languages.md

src/content/docs/en/guides/migrate-to-astro/from-nextjs.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,14 @@ Here's how to recreate that in `src/pages/index.astro`, replacing `getStaticProp
504504

505505
- The `<> </>` fragment is not required in Astro templating.
506506

507+
- `key` is a React attribute, and is not an attribute of `li` in Astro.
508+
507509
```astro title="src/pages/index.astro" "class" "</a>" "<a"
508510
---
509511
---
510512
<ul class="plain-list pokeList">
511513
{pokemons.map((pokemon) => (
512-
<li class="pokemonListItem" key={pokemon.name}>
514+
<li class="pokemonListItem">
513515
<a class="pokemonContainer" href={`/pokemon/${pokemon.name}`}>
514516
<p class="pokemonId">No. {pokemon.id}</p>
515517
<img class="pokemonImage" src={`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${pokemon.id}.png`} alt={`${pokemon.name} picture`}/>
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
title: Prefetch
3+
description: Prefetch links for snappier navigation between pages.
4+
i18nReady: true
5+
---
6+
7+
Page load times play a big role in the usability and overall enjoyment of a site. Astro's **opt-in prefetching** brings the benefits of near-instant page navigations to your multi-page application (MPA) as your visitors interact with the site.
8+
9+
## Enable prefetching
10+
11+
You can enable prefetching with the `prefetch` config:
12+
13+
```js title="astro.config.js" ins={4}
14+
import { defineConfig } from 'astro/config';
15+
16+
export default defineConfig({
17+
prefetch: true
18+
})
19+
```
20+
21+
A prefetch script will be added to all pages of your site. You can then add the `data-astro-prefetch` attribute to any `<a />` links on your site to opt-in to prefetching. When you hover over the link, the script will fetch the page in the background.
22+
23+
```html
24+
<a href="/about" data-astro-prefetch>
25+
```
26+
27+
Note that prefetching only works for links within your site, and not external links.
28+
29+
## Prefetch configuration
30+
31+
The `prefetch` config also accepts an option object to further customize prefetching.
32+
33+
### Prefetch strategies
34+
35+
Astro supports 3 prefetch strategies for various use cases:
36+
37+
- `hover` (default): Prefetch when you hover over or focus on the link.
38+
- `tap`: Prefetch just before you click on the link.
39+
- `viewport`: Prefetch as the links enter the viewport.
40+
41+
You can specify a strategy for an individual link by passing it to the `data-astro-prefetch` attribute:
42+
43+
```html
44+
<a href="/about" data-astro-prefetch="tap">About</a>
45+
```
46+
47+
Each strategy is fine-tuned to only prefetch when needed and save your users' bandwidth. For example:
48+
49+
- If a visitor is using [data saver mode](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) or has a [slow connection](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType), prefetching will be turned off.
50+
- Quickly hovering or scrolling over links will not prefetch them.
51+
- Links that use the `viewport` strategy are prefetched with a lower priority to avoid clogging up the network.
52+
53+
### Default prefetch strategy
54+
55+
The default prefetch strategy when adding the `data-astro-prefetch` attribute is `hover`. To change it, you can configure [`prefetch.defaultStrategy`](/en/reference/configuration-reference/#prefetchdefaultstrategy) in your `astro.config.js` file:
56+
57+
```js title="astro.config.js" ins={4-6}
58+
import { defineConfig } from 'astro/config';
59+
60+
export default defineConfig({
61+
prefetch: {
62+
defaultStrategy: 'viewport'
63+
}
64+
})
65+
```
66+
67+
### Prefetch all links by default
68+
69+
If you want to prefetch all links, including those without the `data-astro-prefetch` attribute, you can set [`prefetch.prefetchAll`](/en/reference/configuration-reference/#prefetchprefetchall) to `true`:
70+
71+
```js title="astro.config.js" ins={4-6}
72+
import { defineConfig } from 'astro/config';
73+
74+
export default defineConfig({
75+
prefetch: {
76+
prefetchAll: true
77+
}
78+
})
79+
```
80+
81+
You can then opt-out of prefetching for individual links by setting `data-astro-prefetch="false"`:
82+
83+
```html
84+
<a href="/about" data-astro-prefetch="false">About</a>
85+
```
86+
87+
The default prefetch strategy for all links can be changed with `prefetch.defaultStrategy` as shown in the [Default prefetch strategy section](#default-prefetch-strategy).
88+
89+
## Prefetch programmatically
90+
91+
As some navigation might not always appear as `<a />` links, you can also prefetch programmatically with the `prefetch()` API from the `astro:prefetch` module:
92+
93+
```astro
94+
<button id="btn">Click me</button>
95+
96+
<script>
97+
import { prefetch } from 'astro:prefetch';
98+
99+
const btn = document.getElementById('btn');
100+
btn.addEventListener('click', () => {
101+
prefetch('/about');
102+
});
103+
</script>
104+
```
105+
106+
You can additionally configure the priority of prefetching by passing the `with` option:
107+
108+
```js
109+
// Prefetch with `fetch()`, which has a higher priority.
110+
prefetch('/about', { with: 'fetch' });
111+
112+
// Prefetch with `<link rel="prefetch">`, which has a lower priority
113+
// and manually scheduled by the browser. (default)
114+
prefetch('/about', { with: 'link' });
115+
```
116+
117+
The `prefetch()` API includes the same [data saver mode](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/saveData) and [slow connection](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType) detection, so that it only prefetches when needed.
118+
119+
Make sure to only import `prefetch()` in client-side scripts as it relies on browser APIs.
120+
121+
## Using with View Transitions
122+
123+
When you use [View Transitions](/en/guides/view-transitions/) on a page, prefetching will also be enabled by default. It sets a default configuration of `{ prefetchAll: true }` which enables [prefetching for all links](#prefetch-all-links-by-default) on the page.
124+
125+
You can customize the prefetch configuration in `astro.config.js` to override the default. For example:
126+
127+
```js title="astro.config.js"
128+
import { defineConfig } from 'astro/config';
129+
130+
export default defineConfig({
131+
// Disable prefetch completely
132+
prefetch: false
133+
})
134+
```
135+
136+
```js title="astro.config.js"
137+
import { defineConfig } from 'astro/config';
138+
139+
export default defineConfig({
140+
// Keep prefetch, but only prefetch for links with `data-astro-prefetch`
141+
prefetch: {
142+
prefetchAll: false
143+
}
144+
})
145+
```
146+
147+
## Migrating from `@astrojs/prefetch`
148+
149+
The `@astrojs/prefetch` integration was deprecated in v3.5.0 and will eventually be removed entirely. Use the following instructions to migrate to Astro's built-in prefetching which replaces this integration.
150+
151+
1. Remove the `@astrojs/prefetch` integration and enable the `prefetch` config in `astro.config.js`:
152+
153+
```js title="astro.config.js" ins={6} del={2,5}
154+
import { defineConfig } from 'astro/config';
155+
import prefetch from '@astrojs/prefetch';
156+
157+
export default defineConfig({
158+
integrations: [prefetch()],
159+
prefetch: true
160+
})
161+
```
162+
163+
2. Convert from `@astrojs/prefetch`'s configuration options:
164+
165+
- The deprecated integration used the `selector` config option to specify which links should be prefetched upon entering the viewport.
166+
167+
Add `data-astro-prefetch="viewport"` to these individual links instead.
168+
169+
```html
170+
<a href="/about" data-astro-prefetch="viewport">
171+
```
172+
173+
- The deprecated integration used the `intentSelector` config option to specify which links should be prefetched when they were hovered over or focused.
174+
175+
Add `data-astro-prefetch` or `data-astro-prefetch="hover"` to these individual links instead:
176+
177+
```html
178+
<!-- You can omit the value if `defaultStrategy` is set to `hover` (default) -->
179+
<a href="/about" data-astro-prefetch>
180+
181+
<!-- Otherwise, you can explicitly define the prefetch strategy -->
182+
<a href="/about" data-astro-prefetch="hover">
183+
```
184+
185+
- The `throttles` option from `@astrojs/prefetch` is no longer needed as the new prefetch feature will automatically schedule and prefetch optimally.

src/content/docs/en/recipes.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ Add your own here! See our [recipes contributing guide](https://github.com/witha
3838
- [Add Github OAuth with Lucia](https://lucia-auth.com/guidebook/github-oauth/astro)
3939
- [Integrating Sentry with Astro](https://akashrajpurohit.com/blog/seamless-error-tracking-integrating-sentry-with-astro/)
4040
- [Set Up Draft Pages Effectively in Astro with Config-Driven Content Authoring](https://akashrajpurohit.com/blog/set-up-draft-pages-effectively-in-astro-with-configdriven-content-authoring/)
41+
- [How to Send Any Data to Your RSS Feed? A Guide with Astro + RSS](https://aritraroy.live/tutorial/blogs/2023/how-to-send-any-data-to-rss-feed/)

0 commit comments

Comments
 (0)