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**

**After**

**Before**

**After**

This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user