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:
@@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"total": 35
|
"total": 35,
|
||||||
|
"🟢": 12,
|
||||||
|
"🟠": 116,
|
||||||
|
"🔴": 207
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: <%= difficulty %> <%= title %>
|
title: <%= difficulty %> <%= title %>
|
||||||
description: Challenge <%= challengeNumber %> is about ...
|
description: Challenge <%= challengeNumber %> is about ...
|
||||||
sidebar:
|
sidebar:
|
||||||
order: <%= challengeNumber %>
|
order: <%= order %>
|
||||||
---
|
---
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|||||||
@@ -20,8 +20,13 @@ import { Schema } from './schema';
|
|||||||
export async function challengeGenerator(tree: Tree, options: Schema) {
|
export async function challengeGenerator(tree: Tree, options: Schema) {
|
||||||
const { appDirectory } = getProjectDir(options.name, options.directory);
|
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 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, {
|
await applicationGenerator(tree, {
|
||||||
...options,
|
...options,
|
||||||
@@ -60,7 +65,8 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
|
|||||||
projectName: names(options.name).name,
|
projectName: names(options.name).name,
|
||||||
title: options.title,
|
title: options.title,
|
||||||
challengeNumber,
|
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');
|
await writeFile('./docs/src/content/docs/index.mdx', replaced, 'utf-8');
|
||||||
|
|
||||||
updateJson(tree, challengeNumberPath, (json) => {
|
updateJson(tree, challengeNumberPath, (json) => {
|
||||||
json.total = json.total + 1;
|
json.total += 1;
|
||||||
|
json[difficulty] += 1;
|
||||||
return json;
|
return json;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user