chore: bump prettier, re-enable prettier for docs (#11695)

## Introducing Prettier for docs

Prettier [was originally disabled for our docs as it didn't support MDX
2.0](1fa636417f),
outputting invalid MDX syntax.

This has since been fixed - prettier now supports MDX 2.0.

## Reducing print width

This also reduces the print width for the docs folder from 100 to 70.
Our docs code field are very narrow - this should help make code more
readable.

**Before**
![CleanShot 2025-03-13 at 19 58
11@2x](https://github.com/user-attachments/assets/0ae9e27b-cddf-44e5-a978-c8e24e99a314)

**After**

![CleanShot 2025-03-13 at 19 59
19@2x](https://github.com/user-attachments/assets/0e424f99-002c-4adc-9b37-edaeef239b0d)



**Before**
![CleanShot 2025-03-13 at 20 00
05@2x](https://github.com/user-attachments/assets/614e51b3-aa0d-45e7-98f4-fcdb1a778bcf)

**After**

![CleanShot 2025-03-13 at 20 00
16@2x](https://github.com/user-attachments/assets/be46988a-2cba-43fc-a8cd-fd3c781da930)
This commit is contained in:
Alessio Gravili
2025-03-14 11:13:08 -06:00
committed by GitHub
parent 9ea8a7acf0
commit 9f9db3ff81
121 changed files with 3721 additions and 3404 deletions

View File

@@ -9,9 +9,9 @@ keywords: local api, config, configuration, documentation, Content Management Sy
Payload can be used completely outside of Next.js which is helpful in cases like running scripts, using Payload in a separate backend service, or using Payload's Local API to fetch your data directly from your database in other frontend frameworks like SvelteKit, Remix, Nuxt, and similar.
<Banner>
**Note:**
Payload and all of its official packages are fully ESM. If you want to use Payload within your own projects, make sure you are writing your scripts in ESM format or dynamically importing the Payload Config.
**Note:** Payload and all of its official packages are fully ESM. If you want
to use Payload within your own projects, make sure you are writing your
scripts in ESM format or dynamically importing the Payload Config.
</Banner>
## Importing the Payload Config outside of Next.js
@@ -32,8 +32,8 @@ const seed = async () => {
collection: 'users',
data: {
email: 'dev@payloadcms.com',
password: 'some-password'
}
password: 'some-password',
},
})
const page = await payload.create({
@@ -41,7 +41,7 @@ const seed = async () => {
data: {
title: 'My Homepage',
// other data to seed here
}
},
})
}
@@ -67,6 +67,7 @@ If you encounter import-related errors, you have 2 options:
#### Option 1: enable swc mode by appending `--use-swc` to the `payload` command:
Example:
```sh
payload run src/seed.ts --use-swc
```

View File

@@ -11,7 +11,8 @@ The Payload Local API gives you the ability to execute the same operations that
<Banner type="success">
**Tip:**
The Local API is incredibly powerful when used in React Server Components and other similar server-side contexts. With other headless CMS, you need to request your data from third-party servers via an HTTP layer, which can add significant loading time to your server-rendered pages. With Payload, you don't have to leave your server to gather the data you need. It can be incredibly fast and is definitely a game changer.
The Local API is incredibly powerful when used in React Server Components and other similar server-side contexts. With other headless CMS, you need to request your data from third-party servers via an HTTP layer, which can add significant loading time to your server-rendered pages. With Payload, you don't have to leave your server to gather the data you need. It can be incredibly fast and is definitely a game changer.
</Banner>
Here are some common examples of how you can use the Local API:
@@ -32,7 +33,9 @@ In most places within Payload itself, you can access `payload` directly from the
Example:
```ts
const afterChangeHook: CollectionAfterChangeHook = async ({ req: { payload } }) => {
const afterChangeHook: CollectionAfterChangeHook = async ({
req: { payload },
}) => {
const posts = await payload.find({
collection: 'posts',
})
@@ -94,8 +97,9 @@ const post = await payload.find({
<Banner type="warning">
**Note:**
By default, all access control checks are disabled in the Local API, but you can re-enable them if
you'd like, as well as pass a specific user to run the operation with.
By default, all access control checks are disabled in the Local API, but you can re-enable them if
you'd like, as well as pass a specific user to run the operation with.
</Banner>
## Collections
@@ -325,7 +329,7 @@ available:
// responseHeaders: { ... } // returned headers from the response
// }
const result = await payload.auth({headers})
const result = await payload.auth({ headers })
```
### Login