mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(doc): create challenge generator now support order by difficulty
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
title: <%= difficulty %> <%= title %>
|
||||
description: Challenge <%= challengeNumber %> is about ...
|
||||
sidebar:
|
||||
order: <%= challengeNumber %>
|
||||
order: <%= order %>
|
||||
---
|
||||
|
||||
:::note
|
||||
|
||||
@@ -20,8 +20,13 @@ import { Schema } from './schema';
|
||||
export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||
const { appDirectory } = getProjectDir(options.name, options.directory);
|
||||
|
||||
const difficulty = options.challengeDifficulty;
|
||||
|
||||
// read json file with the total challanges and display order
|
||||
const challengeNumberPath = 'challenge-number.json';
|
||||
const challengeNumber = readJsonFile(challengeNumberPath).total;
|
||||
const challangeNumberJson = readJsonFile(challengeNumberPath);
|
||||
const challengeNumber = challangeNumberJson.total;
|
||||
const order = challangeNumberJson[difficulty] + 1;
|
||||
|
||||
await applicationGenerator(tree, {
|
||||
...options,
|
||||
@@ -60,7 +65,8 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||
projectName: names(options.name).name,
|
||||
title: options.title,
|
||||
challengeNumber,
|
||||
difficulty: options.challengeDifficulty,
|
||||
difficulty,
|
||||
order,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -90,7 +96,8 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||
await writeFile('./docs/src/content/docs/index.mdx', replaced, 'utf-8');
|
||||
|
||||
updateJson(tree, challengeNumberPath, (json) => {
|
||||
json.total = json.total + 1;
|
||||
json.total += 1;
|
||||
json[difficulty] += 1;
|
||||
return json;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user