Skip to content

Commit db6b1b0

Browse files
committed
feat(index-fields): differentiate nested/non-nested collections
1 parent 4c99ad1 commit db6b1b0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/decap-cms-core/src/components/Collection/Entries/EntryCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function mapStateToProps(state, ownProps) {
148148
const isLoadingAsset = selectIsLoadingAsset(state.medias);
149149

150150
const indexFileConfig = collection.get('index_file');
151-
const fileSlug = entry.get('slug')?.split('/').pop();
151+
const fileSlug = entry.get('slug');
152152

153153
return {
154154
summary,

packages/decap-cms-core/src/reducers/collections.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function collections(state = defaultState, action: ConfigAction) {
4343
}
4444
}
4545

46-
function isIndexFile(filePath: string, pattern: string) {
47-
const fileSlug = filePath?.split('/').pop();
46+
function isIndexFile(filePath: string, pattern: string, nested: boolean) {
47+
const fileSlug = nested ? filePath?.split('/').pop() : filePath;
4848
return fileSlug && new RegExp(pattern).test(fileSlug);
4949
}
5050

@@ -64,7 +64,7 @@ const selectors = {
6464
const indexFileConfig = collection.get('index_file');
6565
if (
6666
indexFileConfig &&
67-
isIndexFile(slug, indexFileConfig.get('pattern')) &&
67+
isIndexFile(slug, indexFileConfig.get('pattern'), !!collection.get('nested')) &&
6868
indexFileConfig.has('fields')
6969
) {
7070
return indexFileConfig.get('fields');

0 commit comments

Comments
 (0)