You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ReadMore>Learn more about Astro’s Markdown and MDX support in our [Markdown/MDX guide](/en/guides/markdown-content/).</ReadMore>
240
240
241
-
## Using one Layout for `.md`, `.mdx`, and `.astro`
241
+
###Using TypeScript with layouts
242
242
243
-
A single Astro layout can be written to receive the `frontmatter` object from `.md` and `.mdx` files, as well as any named props passed from `.astro` files.
243
+
Any astro layout can be modified to introduce typesafety & autocompletion by providing the types for your props:
244
244
245
-
In the example below, the layout will display the page title either from a frontmatter YAML `title` property or from an Astro component passing a `title` attribute:
Copy file name to clipboardExpand all lines: src/content/docs/en/basics/project-structure.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,10 @@ For help creating a new `package.json` file for your project, check out the [man
118
118
119
119
This file is generated in every starter template and includes configuration options for your Astro project. Here you can specify integrations to use, build options, server options, and more.
120
120
121
+
Astro supports several file formats for its JavaScript configuration file: `astro.config.js`, `astro.config.mjs`, `astro.config.cjs` and `astro.config.ts`. We recommend using `.mjs` in most cases or `.ts` if you want to write TypeScript in your config file.
122
+
123
+
TypeScript config file loading is handled using [`tsm`](https://github.com/lukeed/tsm) and will respect your project's `tsconfig` options.
124
+
121
125
See the [Configuring Astro Guide](/en/guides/configuring-astro/) for details on setting configurations.
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/authentication.mdx
+73-1Lines changed: 73 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ import ReadMore from '~/components/ReadMore.astro'
9
9
10
10
Authentication and authorization are two security processes that manage access to your website or app. Authentication verifies a visitor's identity, while authorization grants access to protected areas and resources.
11
11
12
-
Authentication allows you to customize areas of your site for logged-in individuals and provides the greatest protection for personal or private information. Authentication libraries (e.g. [Lucia Auth](https://lucia-auth.com/), [Auth.js](https://authjs.dev/)) provide utilities for multiple authentication methods such as email sign-in and OAuth providers.
12
+
Authentication allows you to customize areas of your site for logged-in individuals and provides the greatest protection for personal or private information. Authentication libraries (e.g. [Lucia Auth](https://lucia-auth.com/), [Auth.js](https://authjs.dev/), [Clerk](https://clerk.com)) provide utilities for multiple authentication methods such as email sign-in and OAuth providers.
13
13
14
14
:::tip
15
15
There is no official authentication solution for Astro, but you can find [community "auth" integrations](https://astro.build/integrations/?search=auth) in the integrations directory.
-[`auth-astro` on GitHub](https://github.com/nowaythatworked/auth-astro?tab=readme-ov-file#auth-astro)
189
189
-[Auth.js documentation](https://authjs.dev/)
190
190
191
+
## Clerk
192
+
193
+
Clerk is a complete suite of embeddable UIs, flexible APIs, and admin dashboards to authenticate and manage your users. An [official Clerk SDK for Astro](https://clerk.com/docs/references/astro/overview) is available.
194
+
195
+
### Installation
196
+
197
+
Install `@clerk/astro` using the package manager of your choice.
198
+
199
+
<PackageManagerTabs>
200
+
<Fragmentslot="npm">
201
+
```shell
202
+
npm install @clerk/astro
203
+
```
204
+
</Fragment>
205
+
<Fragmentslot="pnpm">
206
+
```shell
207
+
pnpm add @clerk/astro
208
+
```
209
+
</Fragment>
210
+
<Fragmentslot="yarn">
211
+
```shell
212
+
yarn add @clerk/astro
213
+
```
214
+
</Fragment>
215
+
</PackageManagerTabs>
216
+
217
+
### Configuration
218
+
219
+
Follow [Clerk's own Astro Quickstart guide](https://clerk.com/docs/quickstarts/astro) to set up Clerk integration and middleware in your Astro project.
220
+
221
+
### Usage
222
+
223
+
Clerk provides components that allow you to control the visibility of pages based on your user's authentication state. Show logged out users a sign in button instead of the content available to users who are logged in:
224
+
225
+
```astro title="src/pages/index.astro"
226
+
---
227
+
import Layout from 'src/layouts/Base.astro';
228
+
import { SignedIn, SignedOut, UserButton, SignInButton } from '@clerk/astro/components';
229
+
---
230
+
231
+
<Layout>
232
+
<SignedIn>
233
+
<UserButton />
234
+
</SignedIn>
235
+
<SignedOut>
236
+
<SignInButton />
237
+
</SignedOut>
238
+
</Layout>
239
+
```
240
+
241
+
Clerk also allows you to protect routes on the server using middleware. Specify which routes are protected, and prompt unauthenticated users to sign in:
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/routing.mdx
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -471,7 +471,7 @@ interface Page<T = any> {
471
471
total:number;
472
472
/** the current page number, starting from 1 */
473
473
currentPage:number;
474
-
/** number of items per page (default: 25) */
474
+
/** number of items per page (default: 10) */
475
475
size:number;
476
476
/** number of last page */
477
477
lastPage:number;
@@ -482,10 +482,16 @@ interface Page<T = any> {
482
482
prev:string|undefined;
483
483
/** url of the next page (if there is one) */
484
484
next:string|undefined;
485
+
/** url of the first page (if the current page is not the first page) */
486
+
first:string|undefined;
487
+
/** url of the last page (if the current page in not the last page) */
488
+
last:string|undefined;
485
489
};
486
490
}
487
491
```
488
492
493
+
<ReadMore>Learn more about [the pagination `page` prop](/en/reference/api-reference/#the-pagination-page-prop).</ReadMore>
494
+
489
495
### Nested Pagination
490
496
491
497
A more advanced use-case for pagination is **nested pagination.** This is when pagination is combined with other dynamic route params. You can use nested pagination to group your paginated collection by some property or tag.
Copy file name to clipboardExpand all lines: src/content/docs/en/install-and-setup.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,10 @@ Prefer to try Astro in your browser? Visit [astro.new](https://astro.new/) to br
22
22
-**Text editor** - We recommend [VS Code](https://code.visualstudio.com/) with our [Official Astro extension](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode).
23
23
-**Terminal** - Astro is accessed through its command-line interface (CLI).
24
24
25
+
## Browser compatibility
26
+
27
+
Astro is built with Vite which targets browsers with modern JavaScript support by default. For a complete reference, you can see the [list of currently supported browser versions in Vite](https://vitejs.dev/guide/build.html#browser-compatibility).
0 commit comments