feat(plugin-redirects): added new option for redirect type in the redirects collection (#7625)

You can now add a redirect type to your redirects if needed:

```ts
// Supported types
redirectTypes: ['301', '302'],

// Override the select field
redirectTypeFieldOverride: {
  label: 'Redirect Type (Overridden)',
},
```
This commit is contained in:
Paul
2024-08-11 13:18:49 -06:00
committed by GitHub
parent fa3d250053
commit 5dfcffa281
6 changed files with 60 additions and 3 deletions

View File

@@ -42,6 +42,10 @@ export default buildConfigWithDefaults({
]
},
},
redirectTypes: ['301', '302'],
redirectTypeFieldOverride: {
label: 'Redirect Type (Overridden)',
},
}),
],
typescript: {

View File

@@ -49,6 +49,7 @@ describe('@payloadcms/plugin-redirects', () => {
value: page.id,
},
},
type: '301',
},
})
@@ -66,6 +67,7 @@ describe('@payloadcms/plugin-redirects', () => {
type: 'custom',
url: '/test',
},
type: '301',
},
})

View File

@@ -17,6 +17,9 @@ export interface Config {
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
};
db: {
defaultIDType: string;
};
globals: {};
locale: 'en' | 'es' | 'de';
user: User & {
@@ -26,15 +29,20 @@ export interface Config {
export interface UserAuthOperations {
forgotPassword: {
email: string;
password: string;
};
login: {
password: string;
email: string;
password: string;
};
registerFirstUser: {
email: string;
password: string;
};
unlock: {
email: string;
password: string;
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
@@ -80,6 +88,7 @@ export interface Redirect {
} | null;
url?: string | null;
};
type: '301' | '302';
customField?: string | null;
updatedAt: string;
createdAt: string;