Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d86b14a
missing props
ArmandPhilippot Jun 17, 2026
e3ce8fc
select can be null, value not available without narrowing
ArmandPhilippot Jun 17, 2026
9ad33da
redirect can be null
ArmandPhilippot Jun 17, 2026
6950d58
unclosed script tag
ArmandPhilippot Jun 17, 2026
a8ceed4
consistency, wrap in script tags
ArmandPhilippot Jun 17, 2026
64defa6
nit, import statement for setupStuff
ArmandPhilippot Jun 17, 2026
4997782
btn is HTMLElement | null
ArmandPhilippot Jun 17, 2026
9eda4d8
forEach doesn't work with HTMLCollectionOf, getAttribute can be null
ArmandPhilippot Jun 17, 2026
78a0201
ctx.url is URL, redirectToDefaultLocale requires ctx, async useless
ArmandPhilippot Jun 17, 2026
b1c4270
missing `context.`
ArmandPhilippot Jun 17, 2026
3e25ebc
missing import
ArmandPhilippot Jun 17, 2026
6ad586a
id can be undefined and if infered TS complains because string type
ArmandPhilippot Jun 17, 2026
7c7c5ed
TS complains about params without APIRoute
ArmandPhilippot Jun 17, 2026
002fcf8
APIRoute missing and TS complains without @types/node
ArmandPhilippot Jun 17, 2026
309e81e
missing import
ArmandPhilippot Jun 17, 2026
044d9f9
missing APIRoute
ArmandPhilippot Jun 17, 2026
07c5a7e
TS-friendly pagination
ArmandPhilippot Jun 17, 2026
c15018c
consistent getStaticPaths notation
ArmandPhilippot Jun 17, 2026
714dda7
missing closing fence + TS friendly
ArmandPhilippot Jun 17, 2026
fd820ff
missing import
ArmandPhilippot Jun 17, 2026
a904919
cast is not needed with GetStaticPaths
ArmandPhilippot Jun 17, 2026
44d1c60
Merge branch 'main' into armand/fix-guides-code-snippets
ArmandPhilippot Jun 18, 2026
7bc1fdd
Merge branch 'main' into armand/fix-guides-code-snippets
ArmandPhilippot Jun 30, 2026
c034e0b
move changes made to view transitions and endpoints to other PRs
ArmandPhilippot Jun 30, 2026
f477daf
extract changes made to routing in another PR
ArmandPhilippot Jun 30, 2026
b33dab1
Merge branch 'main' into armand/fix-guides-code-snippets
yanthomasdev Jul 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/content/docs/en/guides/internationalization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ Astro provides helper functions for your middleware so you can control your own
```js title="src/middleware.js"
import { defineMiddleware } from "astro:middleware";
import { redirectToDefaultLocale } from "astro:i18n"; // function available with `manual` routing
export const onRequest = defineMiddleware(async (ctx, next) => {
if (ctx.url.startsWith("/about")) {
export const onRequest = defineMiddleware((ctx, next) => {
if (ctx.url.pathname.startsWith("/about")) {
return next();
} else {
return redirectToDefaultLocale(302);
return redirectToDefaultLocale(ctx, 302);
}
})
```
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/en/guides/middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ When you have multiple middleware functions chained via [sequence()](#chaining-m
Calling `next()` with this signature will create a new `Request` object using the old `ctx.request`. This means that trying to consume `Request.body`, either before or after this rewrite, will throw a runtime error. This error is often raised with [Astro Actions that use HTML forms](/en/guides/actions/#call-actions-from-an-html-form-action). In these cases, we recommend handling rewrites from your Astro templates using `Astro.rewrite()` instead of using middleware.

```js title="src/middleware.js"
import { sequence } from "astro:middleware";

// Current URL is https://example.com/blog

// First middleware function
Expand Down
12 changes: 7 additions & 5 deletions src/content/docs/en/guides/prefetch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ As some navigation might not always appear as `<a />` links, you can also prefet
import { prefetch } from 'astro:prefetch';

const btn = document.getElementById('btn');
btn.addEventListener('click', () => {
btn?.addEventListener('click', () => {
prefetch('/about');
});
</script>
Expand Down Expand Up @@ -158,11 +158,13 @@ To use `prefetch()` programmatically with large sets of links, you can set `eage
<a class="link-moderate" href="/nice-link-20">A Nice Link 20</a>

<script>
import { prefetch } from 'astro:prefetch';
import { prefetch } from "astro:prefetch";

const linkModerate = document.getElementsByClassName('link-moderate');
linkModerate.forEach((link) => prefetch(link.getAttribute('href'), {eagerness: 'moderate'}));

const linkModerate = document.getElementsByClassName("link-moderate");
for (const link of linkModerate) {
const href = link.getAttribute("href");
if (href) prefetch(href, { eagerness: "moderate" });
}
</script>
```

Expand Down
5 changes: 3 additions & 2 deletions src/content/docs/en/guides/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@ Astro includes helpers for working with the types returned by your [`getStaticPa

You can get the type of [`Astro.params`](/en/reference/api-reference/#params) with `InferGetStaticParamsType` and the type of [`Astro.props`](/en/reference/api-reference/#props) with `InferGetStaticPropsType` or you can use `GetStaticPaths` to infer both at once:

```astro title="src/pages/posts/[...id].astro" {2-6,18-19} "satisfies GetStaticPaths;"
```astro title="src/pages/posts/[...id].astro" {2-6,19-20} "satisfies GetStaticPaths;"
---
import type {
InferGetStaticParamsType,
InferGetStaticPropsType,
GetStaticPaths,
} from "astro";
import { getCollection } from "astro:content";

export const getStaticPaths = (async () => {
const posts = await getCollection("blog");
Expand All @@ -328,7 +329,7 @@ export const getStaticPaths = (async () => {
type Params = InferGetStaticParamsType<typeof getStaticPaths>;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const { id } = Astro.params as Params;
const { id } = Astro.params;
// ^? { id: string; }

const { title } = Astro.props;
Expand Down
Loading