mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
- add new metadata global with URL, title, description, keywords, Open Graph, Twitter, and image fields - register Metadata global in payload.config.ts - switch frontend layout to generateMetadata() and load metadata values from Payload globals - resolve metadata image relation (ID or populated media) for OG/Twitter images - update live preview globals config to use SiteSettings.slug and HomePage.slug - keep SiteSettings revalidation hook in consistent position within config - regenerate payload-types.ts for new global/schema types
99 lines
1.8 KiB
TypeScript
99 lines
1.8 KiB
TypeScript
import { revalidateGlobal } from '@/utilities/globals'
|
|
import { GlobalConfig } from 'payload'
|
|
|
|
const slug = 'metadata'
|
|
|
|
const revalidate = async () => revalidateGlobal(slug)
|
|
|
|
export const Metadata: GlobalConfig = {
|
|
slug,
|
|
label: 'Metadados',
|
|
admin: {
|
|
group: 'Configurações',
|
|
},
|
|
access: {
|
|
read: () => true,
|
|
update: ({ req: { user } }) => Boolean(user),
|
|
},
|
|
hooks: {
|
|
afterChange: [revalidate],
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'URL',
|
|
label: 'URL',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'title',
|
|
label: 'Título',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Descrição',
|
|
type: 'textarea',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'keywords',
|
|
label: 'Palavras-chave',
|
|
type: 'array',
|
|
required: true,
|
|
fields: [
|
|
{
|
|
name: 'keyword',
|
|
label: 'Palavra-chave',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'openGraph',
|
|
label: 'Open Graph',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'siteName',
|
|
label: 'Nome do Site',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Descrição',
|
|
type: 'textarea',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'twitter',
|
|
label: 'Twitter',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
name: 'creator',
|
|
label: 'Criador',
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Descrição',
|
|
type: 'textarea',
|
|
required: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'image',
|
|
label: 'Imagem',
|
|
type: 'upload',
|
|
relationTo: 'media',
|
|
},
|
|
],
|
|
}
|