Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i18n): fix that unable to delete page with SINGLE_FILE i18n structure #6218

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/netlify-cms-core/src/lib/__tests__/i18n.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/netlify-cms-core/src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
Expand Down