Files
payload/test/plugin-seo/config.ts
Paul 3027a03ad1 feat(plugin-seo): add i18n (#4665)
* Add i18n to plugin SEO

* Add new translations and e2e tests for the SEO plugin

* Update e2e tests to utilise a shared page ID from a create function
2024-01-04 09:18:09 -05:00

72 lines
1.7 KiB
TypeScript

import path from 'path'
import seoPlugin from '../../packages/plugin-seo/src'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults'
import { devUser } from '../credentials'
import { Media } from './collections/Media'
import { Pages } from './collections/Pages'
import { Users } from './collections/Users'
import { seed } from './seed'
const mockModulePath = path.resolve(__dirname, './mocks/mockFSModule.js')
export default buildConfigWithDefaults({
collections: [Users, Pages, Media],
localization: {
defaultLocale: 'en',
fallback: true,
locales: ['en', 'es', 'de'],
},
admin: {
webpack: (config) => ({
...config,
resolve: {
...config.resolve,
alias: {
...config?.resolve?.alias,
fs: mockModulePath,
},
},
}),
},
i18n: {
resources: {
es: {
'plugin-seo': {
autoGenerate: 'Auto-génerar',
},
},
},
},
plugins: [
seoPlugin({
collections: ['pages', 'posts'],
globals: ['settings'],
tabbedUI: true,
uploadsCollection: 'media',
fields: [
{
name: 'ogTitle',
type: 'text',
label: 'og:title',
},
],
generateTitle: (data: any) => `Website.com — ${data?.doc?.title?.value}`,
generateDescription: ({ doc }: any) => doc?.excerpt?.value,
generateURL: ({ doc, locale }: any) =>
`https://yoursite.com/${locale ? locale + '/' : ''}${doc?.slug?.value || ''}`,
}),
],
onInit: async (payload) => {
await payload.create({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
await seed(payload)
},
})