chore: detuplication (#50955)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Naomi Carrigan
2023-07-13 03:46:00 -07:00
committed by GitHub
parent f3ab008f9d
commit ab640abee1
163 changed files with 14750 additions and 14713 deletions

View File

@@ -47,12 +47,12 @@ interface InsertOptions {
function insertStepIntoMeta({ stepNum, stepId }: InsertOptions): void {
const existingMeta = getMetaData();
const oldOrder = [...existingMeta.challengeOrder];
oldOrder.splice(stepNum - 1, 0, [stepId.toString()]);
oldOrder.splice(stepNum - 1, 0, { id: stepId.toString(), title: '' });
// rename all the files in challengeOrder
const challengeOrder = oldOrder.map(([id], index) => [
const challengeOrder = oldOrder.map(({ id }, index) => ({
id,
`Step ${index + 1}`
]);
title: `Step ${index + 1}`
}));
updateMetaData({ ...existingMeta, challengeOrder });
}
@@ -62,10 +62,10 @@ function deleteStepFromMeta({ stepNum }: { stepNum: number }): void {
const oldOrder = [...existingMeta.challengeOrder];
oldOrder.splice(stepNum - 1, 1);
// rename all the files in challengeOrder
const challengeOrder = oldOrder.map(([id], index) => [
const challengeOrder = oldOrder.map(({ id }, index) => ({
id,
`Step ${index + 1}`
]);
title: `Step ${index + 1}`
}));
updateMetaData({ ...existingMeta, challengeOrder });
}
@@ -84,8 +84,7 @@ const updateStepTitles = (): void => {
const filePath = `${getProjectPath()}${fileName}`;
const frontMatter = matter.read(filePath);
const newStepNum =
meta.challengeOrder.findIndex(elem => elem[0] === frontMatter.data.id) +
1;
meta.challengeOrder.findIndex(({ id }) => id === frontMatter.data.id) + 1;
const title = `Step ${newStepNum}`;
const dashedName = `step-${newStepNum}`;
const newData = {