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
description: Challenge 12 about optimizing the number of change detection cycle while scrolling
sidebar:
order: 12
order: 107
---
<div class="chip">Challenge #12</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
title: <%= difficulty %> <%= title %>
description: Challenge <%= challengeNumber %> is about ...
sidebar:
order: <%= challengeNumber %>
order: <%= order %>
---
:::note

View File

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