Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman committed Nov 30, 2023
2 parents d39ed3c + dd80bfa commit 79a0ae3
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 36 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/components/common/modal/Modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@apply fixed
inset-0
overflow-y-auto
z-50
z-[100]
flex
min-h-full
items-center
Expand All @@ -15,7 +15,7 @@

@apply fixed
inset-0
z-50;
z-[100];
}

.CMS_Modal_content {
Expand All @@ -28,6 +28,6 @@
align-middle
shadow-xl
transition-all
z-[51]
z-[101]
outline-none;
}
2 changes: 1 addition & 1 deletion packages/core/src/constants/configSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function getConfigSchema() {
frame: { type: 'boolean' },
},
},
search: { type: 'string' },
search: { type: 'boolean' },
theme: {
type: 'object',
properties: {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ export function folderFormatter<EF extends BaseField>(

const collectionFields = getFields(collection, entry.slug) as Field[];

const slug = slugFormatter(collection, entry.data, slugConfig, collectionFields);

const dateFieldName = selectInferredField(collection, 'date');
const dateField = getField(collectionFields, dateFieldName);
const date = parseDateFromEntry(entry, dateFieldName, dateField) || null;
Expand All @@ -221,7 +219,7 @@ export function folderFormatter<EF extends BaseField>(
const mediaFolder = compileStringTemplate(
folderTemplate,
date,
slug,
entry.slug,
fields,
collectionFields,
processSegment,
Expand Down
98 changes: 78 additions & 20 deletions packages/core/src/lib/util/__tests__/media.util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,50 @@ describe('media.util', () => {
},
});

it('does not transform path if it does not start with media_folder', () => {
const mockConfig = createMockConfig({
collections: [
createMockCollection<UnknownField>({
folder: 'base/folder',
slug: '{{fields.title}}-{{fields.name}}',
fields: [
{
name: 'title',
widget: 'string',
},
{
name: 'name',
widget: 'string',
},
mockBaseImageField,
],
}),
],
media_folder: '/path/to/media/folder/{{slug}}',
public_folder: '/path/to/public/folder/{{slug}}',
});

const mockCollection = mockConfig.collections[0];
const mockImageField = (mockConfig.collections[0] as FolderCollection)
.fields[3] as FileOrImageField;

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'/some/other/path/image.png',
mockEntry,
mockImageField,
),
).toBe('/some/other/path/image.png');
});

describe('top level', () => {
it('should default to top level config media_folder', () => {
const mockConfig = createMockConfig({
Expand Down Expand Up @@ -138,6 +182,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

Expand Down Expand Up @@ -174,6 +219,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

Expand Down Expand Up @@ -211,6 +257,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: '',
data: {},
newRecord: true,
});
Expand Down Expand Up @@ -305,6 +352,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

Expand Down Expand Up @@ -341,6 +389,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

Expand Down Expand Up @@ -378,6 +427,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: '',
data: {},
newRecord: true,
});
Expand Down Expand Up @@ -420,7 +470,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
undefined,
'image.png',
'path/to/media/folder/image.png',
undefined,
undefined,
undefined,
Expand All @@ -438,7 +488,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
undefined,
'image.png',
'path/to/media/folder/image.png',
undefined,
undefined,
undefined,
Expand All @@ -463,7 +513,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand All @@ -484,7 +534,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -518,7 +568,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/collection/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -550,7 +600,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/collection/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -583,7 +633,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/some/other/media/i-am-a-title/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -619,14 +669,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/some/other/media/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -661,14 +712,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/media/folder/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -704,14 +756,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/media/folder/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -748,6 +801,7 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: '',
data: {},
newRecord: true,
});
Expand All @@ -756,7 +810,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/collection/media/folder/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -792,7 +846,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'path/to/collection/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -824,7 +878,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/collection/media/folder/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -857,7 +911,7 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/some/other/media/i-am-a-title/image.png',
mockBaseEntry,
mockImageField,
),
Expand Down Expand Up @@ -893,14 +947,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/some/other/media/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -935,14 +990,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/media/folder/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -978,14 +1034,15 @@ describe('media.util', () => {

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
slug: 'i-am-a-title-fish',
data: { title: 'i am a title', name: 'fish' },
});

expect(
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/media/folder/i-am-a-title-fish/image.png',
mockEntry,
mockImageField,
),
Expand Down Expand Up @@ -1021,7 +1078,8 @@ describe('media.util', () => {
.fields[3] as FileOrImageField;

const mockEntry = createMockEntry({
path: 'path/to/entry/index.md',
path: 'path/to/entry/DRAFT_MEDIA_FILES/index.md',
slug: '',
data: {},
newRecord: true,
});
Expand All @@ -1030,11 +1088,11 @@ describe('media.util', () => {
selectMediaFilePublicPath(
mockConfig,
mockCollection,
'image.png',
'/path/to/collection/media/folder/DRAFT_MEDIA_FILES/image.png',
mockEntry,
mockImageField,
),
).toBe('/path/to/collection/public/folder/image.png');
).toBe('/path/to/collection/public/folder/DRAFT_MEDIA_FILES/image.png');
});
});
});
Expand Down
Loading

0 comments on commit 79a0ae3

Please sign in to comment.