2024-01-03 15:14:09 -05:00
|
|
|
import type {
|
|
|
|
BaseField,
|
|
|
|
Collection,
|
|
|
|
CollectionFile,
|
|
|
|
CollectionFileWithDefaults,
|
|
|
|
CollectionWithDefaults,
|
|
|
|
Field,
|
|
|
|
FilesCollection,
|
|
|
|
FilesCollectionWithDefaults,
|
|
|
|
FolderCollection,
|
|
|
|
FolderCollectionWithDefaults,
|
|
|
|
} from '@staticcms/core';
|
2023-03-30 13:29:09 -04:00
|
|
|
|
2024-01-03 15:14:09 -05:00
|
|
|
export const createMockFolderCollection = <EF extends BaseField>(
|
2023-03-30 13:29:09 -04:00
|
|
|
extra: Partial<Collection<EF>> = {},
|
|
|
|
...fields: Field<EF>[]
|
2024-01-03 15:14:09 -05:00
|
|
|
): FolderCollection<EF> => ({
|
2023-03-30 13:29:09 -04:00
|
|
|
name: 'mock_collection',
|
|
|
|
label: 'Mock Collections',
|
|
|
|
label_singular: 'Mock Collection',
|
|
|
|
description:
|
|
|
|
'The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection.\n',
|
|
|
|
folder: 'mock_collection',
|
|
|
|
summary: '{{title}}',
|
|
|
|
sortable_fields: {
|
|
|
|
fields: ['title'],
|
|
|
|
default: {
|
|
|
|
field: 'title',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
create: true,
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
label: 'Title',
|
|
|
|
name: 'title',
|
|
|
|
widget: 'string',
|
|
|
|
},
|
|
|
|
...fields,
|
|
|
|
],
|
|
|
|
...extra,
|
|
|
|
});
|
2024-01-03 15:14:09 -05:00
|
|
|
|
|
|
|
export const createMockFolderCollectionWithDefaults = <EF extends BaseField>(
|
|
|
|
extra: Partial<CollectionWithDefaults<EF>> = {},
|
|
|
|
...fields: Field<EF>[]
|
|
|
|
): FolderCollectionWithDefaults<EF> => ({
|
|
|
|
...createMockFolderCollection(extra, ...fields),
|
|
|
|
i18n: extra.i18n,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const createMockCollectionFile = <EF extends BaseField>(
|
|
|
|
extra: Partial<CollectionFile<EF>> = {},
|
|
|
|
...fields: Field<EF>[]
|
|
|
|
): CollectionFile<EF> => ({
|
|
|
|
name: 'mock_collection',
|
|
|
|
label: 'Mock Collections',
|
|
|
|
label_singular: 'Mock Collection',
|
|
|
|
file: 'mock_collection.md',
|
|
|
|
description:
|
|
|
|
'The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection.\n',
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
label: 'Title',
|
|
|
|
name: 'title',
|
|
|
|
widget: 'string',
|
|
|
|
},
|
|
|
|
...fields,
|
|
|
|
],
|
|
|
|
...extra,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const createMockCollectionFileWithDefaults = <EF extends BaseField>(
|
|
|
|
extra: Partial<CollectionFileWithDefaults<EF>> = {},
|
|
|
|
...fields: Field<EF>[]
|
|
|
|
): CollectionFileWithDefaults<EF> => ({
|
|
|
|
...createMockCollectionFile(extra, ...fields),
|
|
|
|
i18n: extra.i18n,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const createMockFilesCollection = <EF extends BaseField>(
|
|
|
|
extra: Omit<Partial<FilesCollection<EF>>, 'files'> & Pick<FilesCollection<EF>, 'files'>,
|
|
|
|
): FilesCollection<EF> => ({
|
|
|
|
name: 'mock_collection',
|
|
|
|
label: 'Mock Collections',
|
|
|
|
label_singular: 'Mock Collection',
|
|
|
|
description:
|
|
|
|
'The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection.\n',
|
|
|
|
summary: '{{title}}',
|
|
|
|
sortable_fields: {
|
|
|
|
fields: ['title'],
|
|
|
|
default: {
|
|
|
|
field: 'title',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
...extra,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const createMockFilesCollectionWithDefaults = <EF extends BaseField>(
|
|
|
|
extra: Omit<Partial<FilesCollectionWithDefaults<EF>>, 'files'> &
|
|
|
|
Pick<FilesCollectionWithDefaults<EF>, 'files'>,
|
|
|
|
): FilesCollectionWithDefaults<EF> => ({
|
|
|
|
...createMockFilesCollection(extra),
|
|
|
|
i18n: extra.i18n,
|
|
|
|
files: extra.files,
|
|
|
|
});
|