* feat: builds color palette for light and dark mode, removes all conflicting rgba sass * chore: replaces colors with css vars * chore: adapts blur-bg to be more performant and stable * chore: getting ready for dark mode * chore: removes unused file * chore: reverts input bg * chore: reverses selection in dark mode * feat: builds theme toggler * feat: adds auto mode for theme * feat: establishes light / dark css pattern, updates account and list * chore: migrates more views to gutter component * chore: adapts global, adjusts popups * chore: finishes retrofitting views * feat: moves to medium instead of semi-bold for headlines * feat: introduces new font for rte * feat: updates rich text styles * feat: styles react select in dark mode * chore: styles datepicker, misc refinements * chore: updates style of UploadCard * chore: fixes code styles * chore: styles PerPage * chore: improves styling of column / where selector * feat: improves field errors in dark mode * chore: styles built-in rich text elements * chore: improves styling of rte elements * chore: tweaks
144 lines
3.2 KiB
TypeScript
144 lines
3.2 KiB
TypeScript
import { CollectionConfig } from '../../src/collections/config/types';
|
|
import { PayloadRequest } from '../../src/express/types';
|
|
import { Block } from '../../src/fields/config/types';
|
|
|
|
const validateLocalizationTransform = (hook: string, value, req: PayloadRequest) => {
|
|
if (req.locale !== 'all' && value !== undefined && typeof value !== 'string' && value !== null) {
|
|
console.error(hook, value);
|
|
throw new Error('Locale transformation should happen before hook is called');
|
|
}
|
|
return value;
|
|
};
|
|
|
|
const RichTextBlock: Block = {
|
|
slug: 'richTextBlock',
|
|
labels: {
|
|
singular: 'Rich Text Block',
|
|
plural: 'Rich Text Blocks',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'content',
|
|
localized: true,
|
|
type: 'richText',
|
|
},
|
|
],
|
|
};
|
|
|
|
const LocalizedPosts: CollectionConfig = {
|
|
slug: 'localized-posts',
|
|
labels: {
|
|
singular: 'Localized Post',
|
|
plural: 'Localized Posts',
|
|
},
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
defaultColumns: [
|
|
'title',
|
|
'priority',
|
|
'createdAt',
|
|
],
|
|
enableRichTextRelationship: true,
|
|
},
|
|
access: {
|
|
read: () => true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
label: 'Title',
|
|
type: 'text',
|
|
maxLength: 100,
|
|
required: true,
|
|
unique: true,
|
|
localized: true,
|
|
hooks: {
|
|
beforeValidate: [({ value, req }) => validateLocalizationTransform('beforeValidate', value, req)],
|
|
beforeChange: [({ value, req }) => validateLocalizationTransform('beforeChange', value, req)],
|
|
afterChange: [({ value, req }) => validateLocalizationTransform('afterChange', value, req)],
|
|
afterRead: [({ value, req }) => validateLocalizationTransform('afterRead', value, req)],
|
|
},
|
|
},
|
|
{
|
|
name: 'summary',
|
|
label: 'Summary',
|
|
type: 'text',
|
|
index: true,
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Description',
|
|
type: 'textarea',
|
|
required: true,
|
|
localized: true,
|
|
},
|
|
{
|
|
type: 'richText',
|
|
name: 'richText',
|
|
label: 'Rich Text',
|
|
},
|
|
{
|
|
name: 'priority',
|
|
label: 'Priority',
|
|
type: 'number',
|
|
localized: true,
|
|
},
|
|
{
|
|
name: 'localizedGroup',
|
|
label: 'Localized Group',
|
|
type: 'group',
|
|
localized: true,
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'text',
|
|
label: 'Text',
|
|
},
|
|
{
|
|
type: 'text',
|
|
name: 'demoHiddenField',
|
|
hidden: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
name: 'nonLocalizedGroup',
|
|
label: 'Non-Localized Group',
|
|
type: 'group',
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'text',
|
|
label: 'Text',
|
|
localized: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
type: 'array',
|
|
label: 'Non-Localized Array',
|
|
name: 'nonLocalizedArray',
|
|
maxRows: 3,
|
|
fields: [
|
|
{
|
|
type: 'text',
|
|
name: 'localizedEmbeddedText',
|
|
label: 'Localized Embedded Text',
|
|
localized: true,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: 'Blocks',
|
|
name: 'richTextBlocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
RichTextBlock,
|
|
],
|
|
},
|
|
],
|
|
timestamps: true,
|
|
};
|
|
|
|
export default LocalizedPosts;
|