Link Group

This is a slightly modified version of linkGroup.ts from the Payload website template, the original version can be found hero.

modifications

Localized Label

This is to account for the added localizedLabel in our modified link field.

Code

1import type { ArrayField, Field } from 'payload';
2
3import type { LinkAppearances } from './link';
4
5import deepMerge from '@/src/utils/deepMerge';
6import { link } from './link';
7
8type LinkGroupType = (options?: {
9  appearances?: LinkAppearances[] | false;
10  overrides?: Partial<ArrayField>;
11  localizedLabel?: boolean;
12}) => Field;
13
14export const linkGroup: LinkGroupType = ({
15  appearances,
16  overrides = {},
17  localizedLabel = false,
18} = {}) => {
19  const generatedLinkGroup: Field = {
20    name: 'links',
21    type: 'array',
22    fields: [
23      link({
24        appearances,
25        localizedLabel,
26      }),
27    ],
28  };
29
30  return deepMerge(generatedLinkGroup, overrides);
31};