Merge pull request #155 from tomer953/change-sidebar-order

Change sidebar order
This commit is contained in:
Laforge Thomas
2023-10-02 21:34:35 +02:00
committed by GitHub
37 changed files with 57 additions and 50 deletions

View File

@@ -1,3 +1,6 @@
{ {
"total": 35 "total": 35,
"🟢": 12,
"🟠": 116,
"🔴": 207
} }

View File

@@ -2,7 +2,7 @@
title: 🟠 Optimize Change Detection title: 🟠 Optimize Change Detection
description: Challenge 12 about optimizing the number of change detection cycle while scrolling description: Challenge 12 about optimizing the number of change detection cycle while scrolling
sidebar: sidebar:
order: 12 order: 107
--- ---
<div class="chip">Challenge #12</div> <div class="chip">Challenge #12</div>

View File

@@ -2,7 +2,7 @@
title: 🟢 Default vs OnPush title: 🟢 Default vs OnPush
description: Challenge 34 is about learning the difference between Default and OnPush Change Detection Strategy. description: Challenge 34 is about learning the difference between Default and OnPush Change Detection Strategy.
sidebar: sidebar:
order: 34 order: 7
--- ---
<div class="chip">Challenge #34</div> <div class="chip">Challenge #34</div>

View File

@@ -2,7 +2,7 @@
title: 🟢 Memoization title: 🟢 Memoization
description: Challenge 35 is about learning description: Challenge 35 is about learning
sidebar: sidebar:
order: 35 order: 8
--- ---
<div class="chip">Challenge #35</div> <div class="chip">Challenge #35</div>

View File

@@ -2,7 +2,7 @@
title: 🔴 Utility Wrapper Pipe title: 🔴 Utility Wrapper Pipe
description: Challenge 10 is about creating a pipe to wrap utilities description: Challenge 10 is about creating a pipe to wrap utilities
sidebar: sidebar:
order: 10 order: 202
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Highly Customizable CSS title: 🟠 Highly Customizable CSS
description: Challenge 13 is about creating highly customizable CSS styles description: Challenge 13 is about creating highly customizable CSS styles
sidebar: sidebar:
order: 13 order: 104
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Master Dependancy Injection title: 🔴 Master Dependancy Injection
description: Challenge 16 is about masjering how dependancy injection works description: Challenge 16 is about masjering how dependancy injection works
sidebar: sidebar:
order: 16 order: 203
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Anchor Navigation title: 🟢 Anchor Navigation
description: Challenge 21 is about navigating inside the page with anchor description: Challenge 21 is about navigating inside the page with anchor
sidebar: sidebar:
order: 21 order: 4
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 @RouterInput() title: 🟢 @RouterInput()
description: Challenge 22 is about using the @Input decorator to retreive router params. description: Challenge 22 is about using the @Input decorator to retreive router params.
sidebar: sidebar:
order: 22 order: 5
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Directive Enhancement title: 🟠 Directive Enhancement
description: Challenge 3 is about enhancing a built-in directive description: Challenge 3 is about enhancing a built-in directive
sidebar: sidebar:
order: 3 order: 101
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Interoperability Rxjs/Signal title: 🔴 Interoperability Rxjs/Signal
description: Challenge 30 is about learning how to mix signal with Rxjs description: Challenge 30 is about learning how to mix signal with Rxjs
sidebar: sidebar:
order: 30 order: 204
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Module to Standalone title: 🟢 Module to Standalone
description: Challenge 31 is about migrating a module based application to a standalone application. description: Challenge 31 is about migrating a module based application to a standalone application.
sidebar: sidebar:
order: 31 order: 6
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Change Detection Bug title: 🟠 Change Detection Bug
description: Challenge 32 is about debugging an application that has issue when change detection is triggered description: Challenge 32 is about debugging an application that has issue when change detection is triggered
sidebar: sidebar:
order: 32 order: 105
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Decoupling Components title: 🟠 Decoupling Components
description: Challenge 33 is about decoupling two strongly coupled components using Injection Token description: Challenge 33 is about decoupling two strongly coupled components using Injection Token
sidebar: sidebar:
order: 33 order: 106
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Typed ContextOutlet title: 🔴 Typed ContextOutlet
description: Challenge 4 is about strongly typing ngContextOutlet directives description: Challenge 4 is about strongly typing ngContextOutlet directives
sidebar: sidebar:
order: 4 order: 201
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Crud application title: 🟢 Crud application
description: Challenge 5 is about refactoring a crud application description: Challenge 5 is about refactoring a crud application
sidebar: sidebar:
order: 5 order: 2
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Structural Directive title: 🟠 Structural Directive
description: Challenge 6 is about creating a structural directive to handle permissions description: Challenge 6 is about creating a structural directive to handle permissions
sidebar: sidebar:
order: 6 order: 102
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Pure Pipe title: 🟢 Pure Pipe
description: Challenge 8 is about creating a pure pipe description: Challenge 8 is about creating a pure pipe
sidebar: sidebar:
order: 8 order: 3
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Wrap Function Pipe title: 🟠 Wrap Function Pipe
description: Challenge 9 is about creating a pipe to wrap component fonctions description: Challenge 9 is about creating a pipe to wrap component fonctions
sidebar: sidebar:
order: 9 order: 103
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Effect vs Selector title: 🟠 Effect vs Selector
description: Challenge 2 is about learning the difference between effects and selectors in NgRx description: Challenge 2 is about learning the difference between effects and selectors in NgRx
sidebar: sidebar:
order: 2 order: 113
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Power of Effect title: 🔴 Power of Effect
description: Challenge 7 is about creating an Ngrx effect with another Rxjs Hot observable description: Challenge 7 is about creating an Ngrx effect with another Rxjs Hot observable
sidebar: sidebar:
order: 7 order: 206
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Extend Lib Generator title: 🔴 Extend Lib Generator
description: Challenge 25 is about creating a Nx generator to extend the built-in Library Generator description: Challenge 25 is about creating a Nx generator to extend the built-in Library Generator
sidebar: sidebar:
order: 25 order: 207
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Component Generator title: 🟠 Component Generator
description: Challenge 26 is about creating a Nx generator to create a custom component description: Challenge 26 is about creating a Nx generator to create a custom component
sidebar: sidebar:
order: 26 order: 116
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Custom Eslint Rule title: 🟢 Custom Eslint Rule
description: Challenge 27 is about creating a custom Eslint Rule to forbid enums description: Challenge 27 is about creating a custom Eslint Rule to forbid enums
sidebar: sidebar:
order: 27 order: 12
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 High Order Operator Bug title: 🟠 High Order Operator Bug
description: Challenge 11 is about resolving a Rxjs bug because of high order operators description: Challenge 11 is about resolving a Rxjs bug because of high order operators
sidebar: sidebar:
order: 11 order: 114
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Race Condition title: 🟢 Race Condition
description: Challenge 14 is about race condition in Rxjs description: Challenge 14 is about race condition in Rxjs
sidebar: sidebar:
order: 14 order: 11
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Router title: 🟠 Router
description: Challenge 17 is about testing the router description: Challenge 17 is about testing the router
sidebar: sidebar:
order: 17 order: 108
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Nested Components title: 🟠 Nested Components
description: Challenge 18 is about testing nested components description: Challenge 18 is about testing nested components
sidebar: sidebar:
order: 18 order: 109
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Input Output title: 🟠 Input Output
description: Challenge 19 is about testing inputs and ouputs description: Challenge 19 is about testing inputs and ouputs
sidebar: sidebar:
order: 19 order: 110
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Modal title: 🟠 Modal
description: Challenge 20 is about testing modals description: Challenge 20 is about testing modals
sidebar: sidebar:
order: 20 order: 111
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Harness title: 🟢 Harness
description: Challenge 23 is about testing with component harnesses description: Challenge 23 is about testing with component harnesses
sidebar: sidebar:
order: 23 order: 9
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Harness Creation title: 🟠 Harness Creation
description: Challenge 24 is about creating a component harness. description: Challenge 24 is about creating a component harness.
sidebar: sidebar:
order: 24 order: 112
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟢 Checkbox title: 🟢 Checkbox
description: Challenge 28 is about testing a simple checkbox description: Challenge 28 is about testing a simple checkbox
sidebar: sidebar:
order: 28 order: 10
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🔴 Real-life Application title: 🔴 Real-life Application
description: Challenge 29 is about testing a real-life application description: Challenge 29 is about testing a real-life application
sidebar: sidebar:
order: 29 order: 205
--- ---
:::note :::note

View File

@@ -2,7 +2,7 @@
title: 🟠 Function Overload title: 🟠 Function Overload
description: Challenge 15 is about creating overload functions description: Challenge 15 is about creating overload functions
sidebar: sidebar:
order: 15 order: 115
--- ---
:::note :::note

View File

@@ -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

View File

@@ -12,7 +12,6 @@ import {
updateJson, updateJson,
} from '@nx/devkit'; } from '@nx/devkit';
import { Linter } from '@nx/linter'; import { Linter } from '@nx/linter';
import { readFile, writeFile } from 'fs/promises';
import { join } from 'path'; import { join } from 'path';
import { getProjectDir } from '../../utils/normalize'; import { getProjectDir } from '../../utils/normalize';
import { Schema } from './schema'; import { Schema } from './schema';
@@ -20,8 +19,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 + 1;
const order = challangeNumberJson[difficulty] + 1;
await applicationGenerator(tree, { await applicationGenerator(tree, {
...options, ...options,
@@ -60,7 +64,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,
} }
); );
@@ -70,27 +75,26 @@ export async function challengeGenerator(tree: Tree, options: Schema) {
}); });
} }
const readme = await readFile('./README.md', { encoding: 'utf-8' }); const readme = tree.read('./README.md').toString();
const readmeRegex = new RegExp(`all ${challengeNumber} challenges`); const readmeRegex = new RegExp(`all ${challengeNumber - 1} challenges`);
const readmeReplace = readme.replace( const readmeReplace = readme.replace(
readmeRegex, readmeRegex,
`all ${challengeNumber + 1} challenges` `all ${challengeNumber} challenges`
); );
await writeFile('./README.md', readmeReplace, 'utf-8'); tree.write('./README.md', readmeReplace);
const docs = await readFile('./docs/src/content/docs/index.mdx', { const docs = tree.read('./docs/src/content/docs/index.mdx').toString();
encoding: 'utf-8',
});
const regex = new RegExp(`${challengeNumber} Challenges`, 'gi'); const regex = new RegExp(`${challengeNumber - 1} Challenges`, 'gi');
const replaced = docs.replace(regex, `${challengeNumber + 1} Challenges`); const replaced = docs.replace(regex, `${challengeNumber} Challenges`);
await writeFile('./docs/src/content/docs/index.mdx', replaced, 'utf-8'); tree.write('./docs/src/content/docs/index.mdx', replaced);
updateJson(tree, challengeNumberPath, (json) => { updateJson(tree, challengeNumberPath, (json) => {
json.total = json.total + 1; json.total += 1;
json[difficulty] += 1;
return json; return json;
}); });