fix(generator): fix to add latest challenge

This commit is contained in:
thomas
2023-10-11 20:57:28 +02:00
parent dc9f47e01b
commit a382701e62

View File

@@ -119,14 +119,21 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
const regex = new RegExp(`${challengeNumber - 1} Challenges`, 'gi');
const replaced = docs.replace(regex, `${challengeNumber} Challenges`);
tree.write('./docs/src/content/docs/index.mdx', replaced);
const linkRegex = new RegExp(`link: \\/challenges\\/(.*?)\n`, 'gi');
const replacedLink = replaced.replace(
linkRegex,
`link: /challenges/${options.docRepository}/${challengeNumber}-${
names(options.name).name
}/\n`
);
tree.write('./docs/src/content/docs/index.mdx', replacedLink);
const previousChallengeFilePath = findPreviousChallengeFilePath(
tree,
`./docs/src/content/docs/challenges`,
String(challengeNumber - 1)
);
console.log(`restul`, previousChallengeFilePath);
const previousChallenge = tree.read(previousChallengeFilePath).toString();