Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-seo): image generation handler invalid response #5989

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/plugin-seo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const seo =
const args: Parameters<GenerateImage>[0] =
req.data as unknown as Parameters<GenerateImage>[0]
const result = pluginConfig.generateImage ? await pluginConfig.generateImage(args) : ''
return new Response(result, { status: 200 })
return new Response(JSON.stringify({ result }), { status: 200 })
},
method: 'post',
path: '/plugin-seo/generate-image',
Expand Down
5 changes: 5 additions & 0 deletions test/plugin-seo/collections/Pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export const Pages: CollectionConfig = {
type: 'text',
required: true,
},
{
name: 'photo',
type: 'upload',
relationTo: 'media',
},
{
name: 'excerpt',
label: 'Excerpt',
Expand Down
1 change: 1 addition & 0 deletions test/plugin-seo/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default buildConfigWithDefaults({
],
generateDescription: ({ doc }: any) => doc?.excerpt?.value || 'generated description',
generateTitle: (data: any) => `Website.com — ${data?.doc?.title?.value}`,
generateImage: (data: any) => data.doc?.photo?.value,
generateURL: ({ doc, locale }: any) =>
`https://yoursite.com/${locale ? locale + '/' : ''}${doc?.slug?.value || ''}`,
tabbedUI: true,
Expand Down