feat: add collection for authors

This commit is contained in:
thomas
2023-11-23 22:42:42 +04:00
parent 311d8128b2
commit 6cb5c5c415
88 changed files with 192 additions and 117 deletions

View File

@@ -1,6 +1,6 @@
# Anchor Navigation
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Change Detection Bug
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Typed ContextOutlet
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Crud application
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Decoupling Components
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Master Dependancy Injection
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# InjectionToken
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Interoperability Rxjs/Signal
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Module to Standalone
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Directive Enhancement
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Structural Directive
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Pure Pipe
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Utility Wrapper Pipe
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Wrap Function Pipe
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Projection
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# @RouterInput()
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Highly Customizable CSS
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Effect vs Selector
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Power of Effect
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Default vs OnPush
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Memoization
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# NgFor optimize big list
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# NgFor Optimization
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Optimize Change Detection
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# High Order Operator Bug
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Race Condition
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Checkbox
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Harness Creation
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Harness
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Input Output
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Modal
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Nested Components
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Router
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
<h1>Table testing</h1>
> Author: Thomas Laforge
> author: thomas-laforge
## Statement:

View File

@@ -1,6 +1,6 @@
# Real-life Application
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -1,6 +1,6 @@
# Function Overload
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -0,0 +1,41 @@
---
import { Icon } from '@astrojs/starlight/components';
interface Props {
name: string;
twitter?: string;
linkedin?: string;
github?: string;
}
const { name, twitter, linkedin, github } = Astro.props;
---
<p class="author">
Created by {name}
{twitter && <a href={twitter}><Icon class='icon' name="twitter" size="0.75rem" /></a>}
{linkedin && <a href={linkedin}><Icon class='icon' name="linkedin" size="0.75rem" /></a>}
{github && <a href={github}><Icon class='icon' name="github" size="0.75rem" /></a>}
</p>
<style>
.author {
display: flex;
gap: 0.5rem;
align-items: center;
margin-top: -1rem;
font-size: var(--sl-text-xs);
color: var(--sl-color-gray-3);
}
.icon {
vertical-align: middle;
color: var(--sl-color-gray-3);
&:hover {
color: var(--sl-color-accent-high)
}
}
</style>

View File

@@ -1,15 +1,18 @@
---
import ChallengeFooter from './ChallengeFooter.astro'
import CommentSection from './CommentSection.astro'
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/MarkdownContent.astro';
import type { Props } from '@astrojs/starlight/props';
import { getEntry } from 'astro:content';
import Author from './Author.astro';
import ChallengeFooter from './ChallengeFooter.astro';
import CommentSection from './CommentSection.astro';
const {challengeNumber, author} = Astro.props.entry.data;
const {challengeNumber} = Astro.props.entry.data;
const author = Astro.props.entry.data.author ? await getEntry(Astro.props.entry.data.author) : null;
const renderCommentSection = !Astro.props.entry.data.noCommentSection;
---
{ challengeNumber && author && <p class="author">Created by {author}</p> }
{ challengeNumber && author && <Author {...author.data}/> }
<Default {...Astro.props}><slot /></Default>

View File

@@ -1,5 +1,11 @@
---
interface Props {
link: string;
alt: string;
flag?: 'FR';
}
const { link, alt, flag } = Astro.props;
const isFR = flag === 'FR';
---

View File

@@ -0,0 +1,4 @@
{
"name": "Devesh Chaudhari",
"twitter": "https://twitter.com/DeveshChau"
}

View File

@@ -0,0 +1,6 @@
{
"name": "Thomas Laforge",
"twitter": "https://twitter.com/laforge_toma",
"linkedin": "https://www.linkedin.com/in/thomas-laforge-2b05a945/",
"github": "https://github.com/tomalaforge"
}

View File

@@ -1,23 +1,38 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { defineCollection, z } from 'astro:content';
import { defineCollection, reference, z } from 'astro:content';
const authors = defineCollection({
type: 'data',
schema: z.object({
name: z.string(),
twitter: z.string().url().optional(),
linkedin: z.string().url().optional(),
github: z.string().url().optional(),
}),
});
const docs = defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
noCommentSection: z.boolean().optional().default(false),
challengeNumber: z.union([z.number(), z.boolean()]).default(false),
author: reference('authors').optional(),
command: z.string().optional(),
blogLink: z.string().optional(),
videoLink: z
.object({
link: z.string(),
alt: z.string(),
flag: z.enum(['FR']).optional(),
})
.optional(),
}),
});
const i18n = defineCollection({ type: 'data', schema: i18nSchema() });
export const collections = {
docs: defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
noCommentSection: z.boolean().optional().default(false),
challengeNumber: z.union([z.number(), z.boolean()]).default(false),
author: z.string().optional(),
command: z.string().optional(),
blogLink: z.string().optional(),
videoLink: z
.object({
link: z.string(),
alt: z.string(),
flag: z.enum(['FR']).optional(),
})
.optional(),
}),
}),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
docs: docs,
i18n: i18n,
authors: authors,
};

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Projection
description: Challenge 1 is about learning how to project DOM element through components
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 1
command: angular-projection
blogLink: https://medium.com/@thomas.laforge/create-a-highly-customizable-component-cc3a9805e4c5

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Utility Wrapper Pipe
description: Challenge 10 is about creating a pipe to wrap utilities
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 10
command: angular-pipe-hard
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Highly Customizable CSS
description: Challenge 13 is about creating highly customizable CSS styles
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 13
command: angular-styling
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Master Dependancy Injection
description: Challenge 16 is about masjering how dependancy injection works
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 16
command: angular-di
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Anchor Navigation
description: Challenge 21 is about navigating inside the page with anchor
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 21
command: angular-anchor-scrolling
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 @RouterInput()
description: Challenge 22 is about using the @Input decorator to retreive router params.
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 22
command: angular-router-input
blogLink: https://medium.com/ngconf/accessing-route-params-in-angular-1f8e12770617

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Directive Enhancement
description: Challenge 3 is about enhancing a built-in directive
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 3
command: angular-ngfor-enhancement
blogLink: https://medium.com/@thomas.laforge/ngfor-enhancement-716b44656a6c

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Interoperability Rxjs/Signal
description: Challenge 30 is about learning how to mix signal with Rxjs
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 30
command: angular-interop-rxjs-signal
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Module to Standalone
description: Challenge 31 is about migrating a module based application to a standalone application.
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 31
command: angular-module-to-standalone
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Change Detection Bug
description: Challenge 32 is about debugging an application that has issue when change detection is triggered
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 32
command: angular-bug-cd
blogLink: https://medium.com/ngconf/function-calls-inside-template-are-dangerous-15f9822a6629

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Decoupling Components
description: Challenge 33 is about decoupling two strongly coupled components using Injection Token
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 33
command: angular-decoupling
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 InjectionToken
description: Challenge 39 is about learning the power of dependancy injection
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 39
command: angular-injection-token
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Typed ContextOutlet
description: Challenge 4 is about strongly typing ngContextOutlet directives
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 4
command: angular-context-outlet-type
blogLink: https://medium.com/@thomas.laforge/ngtemplateoutlet-type-checking-5d2dcb07a2c6

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Crud application
description: Challenge 5 is about refactoring a crud application
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 5
command: angular-crud
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Structural Directive
description: Challenge 6 is about creating a structural directive to handle permissions
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 6
command: angular-permissions
blogLink: https://medium.com/@thomas.laforge/create-a-custom-structural-directive-to-manage-permissions-like-a-pro-11a1acad30ad

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Pure Pipe
description: Challenge 8 is about creating a pure pipe
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 8
command: angular-pipe-easy
blogLink: https://medium.com/ngconf/deep-dive-into-angular-pipes-c040588cd15d

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Wrap Function Pipe
description: Challenge 9 is about creating a pipe to wrap component fonctions
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 9
command: angular-pipe-intermediate
blogLink: https://medium.com/ngconf/boost-your-apps-performance-by-wrapping-your-functions-inside-a-pipe-7e889a901d1d

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Effect vs Selector
description: Challenge 2 is about learning the difference between effects and selectors in NgRx
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 2
command: ngrx-effect-selector
blogLink: https://medium.com/@thomas.laforge/ngrx-effect-vs-reducer-vs-selector-58337ab59043

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Power of Effect
description: Challenge 7 is about creating an Ngrx effect with another Rxjs Hot observable
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 7
command: ngrx-notification
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Extend Lib Generator
description: Challenge 25 is about creating a Nx generator to extend the built-in Library Generator
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 25
sidebar:
order: 207

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Component Generator
description: Challenge 26 is about creating a Nx generator to create a custom component
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 26
sidebar:
order: 116
@@ -88,7 +88,7 @@ export class UserStore extends ComponentStore<UserState> implements OnStateInit,
loading: this.loading$,
error: this.error$,
},
{ debounce: true }
{ debounce: true },
);
ngrxOnStateInit() {
@@ -106,11 +106,11 @@ export class UserStore extends ComponentStore<UserState> implements OnStateInit,
this.userService.loadUsers().pipe(
tapResponse(
(users) => this.patchState({ users, loading: false }),
(err: string) => this.patchState({ error: err, loading: false })
)
)
)
)
(err: string) => this.patchState({ error: err, loading: false }),
),
),
),
),
);
}
```

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Custom Eslint Rule
description: Challenge 27 is about creating a custom Eslint Rule to forbid enums
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 27
sidebar:
order: 12

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Optimize Change Detection
description: Challenge 12 about optimizing the number of change detection cycle while scrolling
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 12
command: performance-scroll-cd
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Default vs OnPush
description: Challenge 34 is about learning the difference between Default and OnPush Change Detection Strategy.
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 34
command: performance-default-onpush
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Memoization
description: Challenge 35 is about learning how pure pipe works
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 35
command: performance-memoized
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 NgFor Optimization
description: Challenge 36 is about learning how trackby works
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 36
command: performance-ngfor-optimize
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Optimize Big List
description: Challenge 37 is about learning how virtualization optimize big list rendering
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 37
command: performance-ngfor-biglist
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 High Order Operator Bug
description: Challenge 11 is about resolving a Rxjs bug because of high order operators
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 11
command: rxjs-pipe-bug
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Race Condition
description: Challenge 14 is about race condition in Rxjs
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 14
command: rxjs-race-condition
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 catchError
description: Challenge 38 is about learning obervable completion.
author: Devesh Chaudhari
author: devesh-chaudhari
command: rxjs-catch-error
challengeNumber: 38
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Router
description: Challenge 17 is about testing the router
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 17
command: testing-router-outlet
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Nested Components
description: Challenge 18 is about testing nested components
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 18
command: testing-nested
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Input Output
description: Challenge 19 is about testing inputs and ouputs
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 19
command: testing-input-output
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Modal
description: Challenge 20 is about testing modals
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 20
command: testing-modal
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Harness
description: Challenge 23 is about testing with component harnesses
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 23
command: testing-harness
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Harness Creation
description: Challenge 24 is about creating a component harness.
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 24
command: testing-create-harness
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Checkbox
description: Challenge 28 is about testing a simple checkbox
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 28
command: testing-checkbox
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🔴 Real-life Application
description: Challenge 29 is about testing a real-life application
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 29
command: testing-todos-list
sidebar:

View File

@@ -1,7 +1,7 @@
---
title: 🟠 Function Overload
description: Challenge 15 is about creating overload functions
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 15
command: typescript-overload
blogLink: https://medium.com/ngconf/function-overloading-in-typescript-8236706b2c05

View File

@@ -1,7 +1,7 @@
---
title: 🟢 Proyección
description: Desafio 1 trata sobre aprender a proyectar elementos del DOM a través de componentes,
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 1
command: angular-projection
blogLink: https://medium.com/@thomas.laforge/create-a-highly-customizable-component-cc3a9805e4c5

View File

@@ -1,7 +1,7 @@
---
title: 🟠 InjectionToken
description: Desafio de Angular 39 para aprender sobre el poder del InjectionToken
author: Thomas Laforge
author: thomas-laforge
challengeNumber: 39
command: angular-injection-token
sidebar:

View File

@@ -1,6 +1,6 @@
# <%= title %>
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application

View File

@@ -23,7 +23,7 @@ function findDocFile(
tree: Tree,
path: string,
number: string,
result: string[]
result: string[],
) {
if (!tree.isFile(path)) {
tree.children(path).forEach((child) => {
@@ -59,13 +59,13 @@ async function rewriteFile(tree: Tree, file: string) {
tree,
'./docs/src/content/docs/challenges',
String(number),
result
result,
);
const docFile = result[0];
const pathElts = docFile.split('/');
const link = `https://angular-challenges.vercel.app/challenges/${pathElts.at(
-2
-2,
)}/${pathElts.at(-1)}/`;
const doc = tree.read(docFile);
@@ -89,7 +89,7 @@ async function rewriteFile(tree: Tree, file: string) {
const finalText = `# ${title}
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application
@@ -154,14 +154,14 @@ Your PR title must start with <b>Answer:${number}</b>.
console.log('header', header);
const regexContent = new RegExp(
/Author: Thomas Laforge([\s\S]*?)### Submitting your work/
/author: thomas-laforge([\s\S]*?)### Submitting your work/,
);
const matchContent = buffer.toString().match(regexContent);
let content = '';
if (!matchContent) {
const regexOldContent = new RegExp(
/Author: Thomas Laforge([\s\S]*?)## Submitting your work/
/author: thomas-laforge([\s\S]*?)## Submitting your work/,
);
content = buffer.toString().match(regexOldContent)[1];
} else {

View File

@@ -1,6 +1,6 @@
# Extend Lib Generator
> Author: Thomas Laforge
> author: thomas-laforge
### Documentation and Instruction

View File

@@ -1,6 +1,6 @@
# Component Generator
> Author: Thomas Laforge
> author: thomas-laforge
### Documentation and Instruction

View File

@@ -1,6 +1,6 @@
# Custom Eslint Rule
> Author: Thomas Laforge
> author: thomas-laforge
### Run Application