Skip to content

Commit a14580a

Browse files
fix(i18n): fix that unable to delete page with SINGLE_FILE i18n structure (#6218)
fixes that getFilePaths returns same path twice when i18n structure is SINGLE_FILE
1 parent 17230d1 commit a14580a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/netlify-cms-core/src/lib/__tests__/i18n.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ describe('i18n', () => {
181181
),
182182
).toEqual(['src/content/en/index.md', 'src/content/de/index.md']);
183183
});
184+
185+
it('should return array with single path when structure is I18N_STRUCTURE.SINGLE_FILE', () => {
186+
expect(
187+
i18n.getFilePaths(
188+
fromJS({
189+
i18n: { structure: i18n.I18N_STRUCTURE.SINGLE_FILE, locales: ['en', 'de'] },
190+
}),
191+
...args,
192+
),
193+
).toEqual(['src/content/index.md']);
194+
});
184195
});
185196

186197
describe('normalizeFilePath', () => {

packages/netlify-cms-core/src/lib/i18n.ts

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ export function getFilePaths(
114114
slug: string,
115115
) {
116116
const { structure, locales } = getI18nInfo(collection) as I18nInfo;
117+
118+
if (structure === I18N_STRUCTURE.SINGLE_FILE) {
119+
return [path];
120+
}
121+
117122
const paths = locales.map(locale =>
118123
getFilePath(structure as I18N_STRUCTURE, extension, path, slug, locale),
119124
);

0 commit comments

Comments
 (0)