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
docs: add local api instructions for vercel content link (#12385)
The docs for Vercel Content Link only included instructions on how to
enable content source maps for the REST API. The Local API, although
supported, was lacking documentation.
Copy file name to clipboardExpand all lines: docs/integrations/vercel-content-link.mdx
+37-4Lines changed: 37 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,19 +63,50 @@ const config = buildConfig({
63
63
exportdefaultconfig
64
64
```
65
65
66
-
Now in your Next.js app, include the `?encodeSourceMaps=true` parameter in any of your API requests. For performance reasons, this should only be done when in draft mode or on preview deployments.
66
+
## Enabling Content Source Maps
67
+
68
+
Now in your Next.js app, you need to add the `encodeSourceMaps` query parameter to your API requests. This will tell Payload to include the Content Source Maps in the API response.
69
+
70
+
<Bannertype="warning">
71
+
**Note:** For performance reasons, this should only be done when in draft mode
72
+
or on preview deployments.
73
+
</Banner>
74
+
75
+
#### REST API
76
+
77
+
If you're using the REST API, include the `?encodeSourceMaps=true` search parameter.
67
78
68
79
```ts
69
80
if (isDraftMode||process.env.VERCEL_ENV==='preview') {
If you're using the Local API, include the `encodeSourceMaps` via the `context` property.
90
+
91
+
```ts
92
+
if (isDraftMode||process.env.VERCEL_ENV==='preview') {
93
+
const res =awaitpayload.find({
94
+
collection: 'pages',
95
+
where: {
96
+
slug: {
97
+
equals: slug,
98
+
},
99
+
},
100
+
context: {
101
+
encodeSourceMaps: true,
102
+
},
103
+
})
104
+
}
105
+
```
106
+
76
107
And that's it! You are now ready to enter Edit Mode and begin visually editing your content.
77
108
78
-
####Edit Mode
109
+
## Edit Mode
79
110
80
111
To see Content Link on your site, you first need to visit any preview deployment on Vercel and login using the Vercel Toolbar. When Content Source Maps are detected on the page, a pencil icon will appear in the toolbar. Clicking this icon will enable Edit Mode, highlighting all editable fields on the page in blue.
All `blocks` and `array` fields by definition do not have plain text strings to encode. For this reason, they are given an additional `_encodedSourceMap` property, which you can use to enable Content Link on entire _sections_ of your site. You can then specify the editing container by adding the `data-vercel-edit-target` HTML attribute to any top-level element of your block.
128
+
All `blocks` and `array` fields by definition do not have plain text strings to encode. For this reason, they are automatically given an additional `_encodedSourceMap` property, which you can use to enable Content Link on entire _sections_ of your site.
129
+
130
+
You can then specify the editing container by adding the `data-vercel-edit-target` HTML attribute to any top-level element of your block.
0 commit comments