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
This commit is contained in:
parent
17230d1464
commit
a14580a754
@ -181,6 +181,17 @@ describe('i18n', () => {
|
||||
),
|
||||
).toEqual(['src/content/en/index.md', 'src/content/de/index.md']);
|
||||
});
|
||||
|
||||
it('should return array with single path when structure is I18N_STRUCTURE.SINGLE_FILE', () => {
|
||||
expect(
|
||||
i18n.getFilePaths(
|
||||
fromJS({
|
||||
i18n: { structure: i18n.I18N_STRUCTURE.SINGLE_FILE, locales: ['en', 'de'] },
|
||||
}),
|
||||
...args,
|
||||
),
|
||||
).toEqual(['src/content/index.md']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('normalizeFilePath', () => {
|
||||
|
@ -114,6 +114,11 @@ export function getFilePaths(
|
||||
slug: string,
|
||||
) {
|
||||
const { structure, locales } = getI18nInfo(collection) as I18nInfo;
|
||||
|
||||
if (structure === I18N_STRUCTURE.SINGLE_FILE) {
|
||||
return [path];
|
||||
}
|
||||
|
||||
const paths = locales.map(locale =>
|
||||
getFilePath(structure as I18N_STRUCTURE, extension, path, slug, locale),
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user