Preview button not showing on all collections (?) #1298
-
Hey, I've added preview function to 8 different collections, but for some reason it only appears on a few of them. Are there any configurations that could prevent such a button from being shown? Not really sure if it is a bug, or me missing something crucial Example non-working code (same preview function is used in the working code as well):
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Ahh, noticed it will not appear, unless you have a |
Beta Was this translation helpful? Give feedback.
-
In your above code, You can write another condition or remove the condition and just return the preview URL. As an example: export const Plans: CollectionConfig = {
slug: 'plans',
admin: {
useAsTitle: 'title',
preview: (doc, { locale }) => {
// Always return the same preview URL for the plans collection in each locale
return `https://bigbird.com/preview/plans?locale=${locale}`;
},
},
access: DEFAULT_ACCESS_CONTROL,
fields: [
{
name: 'title',
label: 'Title',
type: 'text',
localized: true,
},
{
name: 'id',
label: 'Custom ID',
type: 'text',
},
buttons,
],
timestamps: false,
} |
Beta Was this translation helpful? Give feedback.
In your above code,
if (doc?.slug)
makes the preview button only show if there's a slug.You can write another condition or remove the condition and just return the preview URL.
As an example: