Skip to content

Commit ccf3134

Browse files
SkyZeroZxalxhub
authored andcommitted
docs: Updates tutorial syntaxis highlight
1 parent 0c4a5c5 commit ccf3134

21 files changed

Lines changed: 115 additions & 109 deletions

File tree

adev/src/content/tutorials/deferrable-views/steps/1-what-are-deferrable-views/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ In this activity, you'll learn how to use deferrable views to defer load a secti
1212
<docs-step title="Add a `@defer` block to a section of a template">
1313
In your `app.ts`, wrap the `article-comments` component with a `@defer` block to defer load it.
1414

15-
<docs-code language="angular-html">
15+
```angular-html
1616
@defer {
1717
<article-comments />
1818
}
19-
</docs-code>
19+
```
2020

2121
By default, `@defer` loads the `article-comments` component when the browser is idle.
2222

2323
In your browser's developer console, you can see that the `article-comments-component` lazy chunk file is loaded separately (The specific file names may change from run to run):
2424

25-
<docs-code language="markdown">
25+
```markdown
2626
Initial chunk files | Names | Raw size
27-
chunk-NNSQHFIE.js | - | 769.00 kB |
27+
chunk-NNSQHFIE.js | - | 769.00 kB |
2828
main.js | main | 229.25 kB |
2929

3030
Lazy chunk files | Names | Raw size
3131
chunk-T5UYXUSI.js | article-comments-component | 1.84 kB |
32-
</docs-code>
32+
```
3333

3434
</docs-step>
3535
</docs-workflow>

adev/src/content/tutorials/deferrable-views/steps/2-loading-error-placeholder/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@ In this activity, you'll learn how to use the `@loading`, `@error` and `@placeho
3939
<docs-step title="Add `@placeholder` block">
4040
In your `app.ts`, add a `@placeholder` block to the `@defer` block.
4141

42-
<docs-code language="angular-html" highlight="[3,4,5]">
42+
```angular-html {highlight:[3,4,5]}
4343
@defer {
4444
<article-comments />
4545
} @placeholder {
4646
<p>Placeholder for comments</p>
4747
}
48-
</docs-code>
48+
```
49+
4950
</docs-step>
5051

5152
<docs-step title="Configure the `@placeholder` block">
5253
The `@placeholder` block accepts an optional parameter to specify the `minimum` amount of time that this placeholder should be shown. This `minimum` parameter is specified in time increments of milliseconds (ms) or seconds (s). This parameter exists to prevent fast flickering of placeholder content in the case that the deferred dependencies are fetched quickly.
5354

54-
<docs-code language="angular-html" highlight="[3,4,5]">
55+
```angular-html {highlight:[3,4,5]}
5556
@defer {
5657
<article-comments />
5758
} @placeholder (minimum 1s) {
5859
<p>Placeholder for comments</p>
5960
}
60-
</docs-code>
61+
```
62+
6163
</docs-step>
6264

6365
<docs-step title="Add `@loading` block">
@@ -72,15 +74,15 @@ Both parameters are specified in time increments of milliseconds (ms) or seconds
7274

7375
Update `app.ts` to include a `@loading` block with a minimum parameter of `1s` as well as an after parameter with the value 500ms to the @loading block.
7476

75-
<docs-code language="angular-html" highlight="[5,6,7]">
77+
```angular-html {highlight:[5,6,7]}
7678
@defer {
7779
<article-comments />
7880
} @placeholder (minimum 1s) {
7981
<p>Placeholder for comments</p>
8082
} @loading (minimum 1s; after 500ms) {
8183
<p>Loading comments...</p>
8284
}
83-
</docs-code>
85+
```
8486

8587
NOTE: this example uses two parameters, separated by the ; character.
8688

@@ -89,7 +91,7 @@ NOTE: this example uses two parameters, separated by the ; character.
8991
<docs-step title="Add `@error` block">
9092
Finally, add an `@error` block to the `@defer` block.
9193

92-
<docs-code language="angular-html" highlight="[7,8,9]">
94+
```angular-html {highlight:[7,8,9]}
9395
@defer {
9496
<article-comments />
9597
} @placeholder (minimum 1s) {
@@ -99,7 +101,8 @@ Finally, add an `@error` block to the `@defer` block.
99101
} @error {
100102
<p>Failed to load comments</p>
101103
}
102-
</docs-code>
104+
```
105+
103106
</docs-step>
104107
</docs-workflow>
105108

adev/src/content/tutorials/deferrable-views/steps/3-defer-triggers/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ In this activity, you'll learn how to use triggers to specify the condition to l
4141
<docs-step title="Add `on hover` trigger">
4242
In your `app.ts`, add an `on hover` trigger to the `@defer` block.
4343

44-
<docs-code language="angular-html" hightlight="[1]">
44+
```angular-html {highlight:[1]}
4545
@defer (on hover) {
4646
<article-comments />
4747
} @placeholder (minimum 1s) {
@@ -51,15 +51,15 @@ In your `app.ts`, add an `on hover` trigger to the `@defer` block.
5151
} @error {
5252
<p>Failed to load comments</p>
5353
}
54-
</docs-code>
54+
```
5555

5656
Now, the page will not render the comments section until you hover its placeholder.
5757
</docs-step>
5858

5959
<docs-step title="Add a 'Show all comments' button">
6060
Next, update the template to include a button with the label "Show all comments". Include a template variable called `#showComments` with the button.
6161

62-
<docs-code language="angular-html" hightlight="[1]">
62+
```angular-html {highlight:[1]}
6363
<button type="button" #showComments>Show all comments</button>
6464
6565
@defer (on hover) {
@@ -72,7 +72,7 @@ Next, update the template to include a button with the label "Show all comments"
7272
} @error {
7373
<p>Failed to load comments</p>
7474
}
75-
</docs-code>
75+
```
7676

7777
NOTE: for more information on [template variables check the documentation](https://angular.dev/guide/templates/reference-variables#).
7878

@@ -81,7 +81,7 @@ NOTE: for more information on [template variables check the documentation](https
8181
<docs-step title="Add `on interaction` trigger">
8282
Update the `@defer` block in the template to use the `on interaction` trigger. Provide the `showComments` template variable as the parameter to `interaction`.
8383

84-
<docs-code language="angular-html" hightlight="[3]">
84+
```angular-html {highlight:[3]}
8585
<button type="button" #showComments>Show all comments</button>
8686
8787
@defer (on hover; on interaction(showComments)) {
@@ -94,7 +94,7 @@ Update the `@defer` block in the template to use the `on interaction` trigger. P
9494
} @error {
9595
<p>Failed to load comments</p>
9696
}
97-
</docs-code>
97+
```
9898

9999
With these changes, the page will wait for one of the following conditions before rendering the comments section:
100100

adev/src/content/tutorials/learn-angular/steps/10-deferrable-views/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,65 @@ The code above is an example of how to use a basic `@defer` block. By default `@
3232

3333
Add a `@placeholder` block to the `@defer` block. The `@placeholder` block is where you put html that will show before the deferred loading starts. The content in `@placeholder` blocks is eagerly loaded.
3434

35-
<docs-code language="angular-html" highlight="[3,4,5]">
35+
```angular-html {highlight:[3,4,5]}
3636
@defer {
3737
<comments />
3838
} @placeholder {
3939
<p>Future comments</p>
4040
}
41-
</docs-code>
41+
```
4242

4343
</docs-step>
4444

4545
<docs-step title="Add a loading block">
4646

4747
Add a `@loading` block to the `@defer` block. The `@loading` block is where you put html that will show _while_ the deferred content is actively being fetched, but hasn't finished yet. The content in `@loading` blocks is eagerly loaded.
4848

49-
<docs-code language="angular-html" highlight="[5,6,7]">
49+
```angular-html {highlight:[5,6,7]}
5050
@defer {
5151
<comments />
5252
} @placeholder {
5353
<p>Future comments</p>
5454
} @loading {
5555
<p>Loading comments...</p>
5656
}
57-
</docs-code>
57+
```
5858

5959
</docs-step>
6060

6161
<docs-step title="Add a minimum duration">
6262

6363
Both `@placeholder` and `@loading` sections have optional parameters to prevent flickering from occurring when loading happens quickly. `@placeholder` has `minimum` and `@loading` has `minimum` and `after`. Add a `minimum` duration to the `@loading` block so it will be rendered for at least 2 seconds.
6464

65-
<docs-code language="angular-html" highlight="[5]">
65+
```angular-html {highlight:[5]}
6666
@defer {
6767
<comments />
6868
} @placeholder {
6969
<p>Future comments</p>
7070
} @loading (minimum 2s) {
7171
<p>Loading comments...</p>
7272
}
73-
</docs-code>
73+
```
7474

7575
</docs-step>
7676

7777
<docs-step title="Add a viewport trigger">
7878

7979
Deferrable views have a number of trigger options. Add a viewport trigger so the content will defer load once it enters the viewport.
8080

81-
<docs-code language="angular-html" highlight="[1]">
81+
```angular-html {highlight:[1]}
8282
@defer (on viewport) {
8383
<comments />
8484
}
85-
</docs-code>
85+
```
8686

8787
</docs-step>
8888

8989
<docs-step title="Add content">
9090

9191
A viewport trigger is best used when you're deferring content that's far enough down the page that it needs to be scrolled to see. So let's add some content to our blog post. You can either write your own, or you can copy the content below and put it inside the `<article>` element.
9292

93-
<docs-code language="html" highlight="[1]">
93+
```html {highlight:[1]}
9494
<article>
9595
<p>Angular is my favorite framework, and this is why. Angular has the coolest deferrable view feature that makes defer loading content the easiest and most ergonomic it could possibly be. The Angular community is also filled with amazing contributors and experts that create excellent content. The community is welcoming and friendly, and it really is the best community out there.</p>
9696
<p>I can't express enough how much I enjoy working with Angular. It offers the best developer experience I've ever had. I love that the Angular team puts their developers first and takes care to make us very happy. They genuinely want Angular to be the best framework it can be, and they're doing such an amazing job at it, too. This statement comes from my heart and is not at all copied and pasted. In fact, I think I'll say these exact same things again a few times.</p>
@@ -99,7 +99,7 @@ A viewport trigger is best used when you're deferring content that's far enough
9999
<p>Angular is my favorite framework, and this is why. Angular has the coolest deferrable view feature that makes defer loading content the easiest and most ergonomic it could possibly be. The Angular community is also filled with amazing contributors and experts that create excellent content. The community is welcoming and friendly, and it really is the best community out there.</p>
100100
<p>I can't express enough how much I enjoy working with Angular. It offers the best developer experience I've ever had. I love that the Angular team puts their developers first and takes care to make us very happy. They genuinely want Angular to be the best framework it can be, and they're doing such an amazing job at it, too. This statement comes from my heart and is not at all copied and pasted.</p>
101101
</article>
102-
</docs-code>
102+
```
103103

104104
Once you've added this code, now scroll down to see the deferred content load once you scroll it into the viewport.
105105

adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { NgOptimizedImage } from '@angular/common';
3131

3232
To enable the `NgOptimizedImage` directive, swap out the `src` attribute for `ngSrc`. This applies for both static image sources (i.e., `src`) and dynamic image sources (i.e., `[src]`).
3333

34-
<docs-code language="angular-ts" highlight="[[9], [13]]">
34+
```angular-ts {highlight:[[9],[13]]}
3535
import { NgOptimizedImage } from '@angular/common';
3636
3737
@Component({
@@ -48,7 +48,7 @@ template: ` ...
4848
`,
4949
imports: [NgOptimizedImage],
5050
})
51-
</docs-code>
51+
```
5252

5353
</docs-step>
5454

adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ In `app.config.ts`, configure the app to Angular Router with the following steps
3333
1. Import `routes` from the `./app.routes.ts`.
3434
1. Call the `provideRouter` function with `routes` passed in as an argument in the `providers` array.
3535

36-
<docs-code language="ts" highlight="[2,3,6]">
36+
```ts {highlight:[2,3,6]}
3737
import {ApplicationConfig} from '@angular/core';
3838
import {provideRouter} from '@angular/router';
3939
import {routes} from './app.routes';
4040

4141
export const appConfig: ApplicationConfig = {
4242
providers: [provideRouter(routes)],
4343
};
44-
</docs-code>
44+
```
4545

4646
</docs-step>
4747

@@ -51,12 +51,13 @@ Finally, to make sure your app is ready to use the Angular Router, you need to t
5151

5252
Update the template for `App` by adding `<router-outlet />`
5353

54-
<docs-code language="angular-ts" highlight="[11]">
54+
```angular-ts {highlight:[11]}
5555
import {RouterOutlet} from '@angular/router';
5656
5757
@Component({
5858
...
59-
template: ` <nav>
59+
template: `
60+
<nav>
6061
<a href="/">Home</a>
6162
|
6263
<a href="/user">User</a>
@@ -66,7 +67,7 @@ template: ` <nav>
6667
imports: [RouterOutlet],
6768
})
6869
export class App {}
69-
</docs-code>
70+
```
7071

7172
</docs-step>
7273

adev/src/content/tutorials/learn-angular/steps/13-define-a-route/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ In addition to defining the routes correctly, Angular Router also enables you to
4343

4444
In `app.routes.ts`, add the `title` property to the default route (`path: ''`) and the `user` route. Here's an example:
4545

46-
<docs-code language="ts" highlight="[8]">
46+
```ts {highlight:[7]}
4747
import {Routes} from '@angular/router';
4848
import {Home} from './home/home';
4949

5050
export const routes: Routes = [
51-
{
52-
path: '',
53-
title: 'App Home Page',
54-
component: Home,
55-
},
51+
{
52+
path: '',
53+
title: 'App Home Page',
54+
component: Home,
55+
},
5656
];
57-
</docs-code>
57+
```
5858

5959
</docs-step>
6060

adev/src/content/tutorials/learn-angular/steps/15-forms/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For this form to use Angular features that enable data binding to forms, you'll
3131

3232
Import the `FormsModule` from `@angular/forms` and add it to the `imports` array of the `User`.
3333

34-
<docs-code language="ts" highlight="[2, 7]">
34+
```ts {highlight:[2,7]}
3535
import {Component} from '@angular/core';
3636
import {FormsModule} from '@angular/forms';
3737

@@ -40,7 +40,7 @@ import {FormsModule} from '@angular/forms';
4040
imports: [FormsModule],
4141
})
4242
export class User {}
43-
</docs-code>
43+
```
4444

4545
</docs-step>
4646

@@ -50,12 +50,12 @@ The `FormsModule` has a directive called `ngModel` that binds the value of the i
5050

5151
Update the input to use the `ngModel` directive, specifically with the following syntax `[(ngModel)]="favoriteFramework"` to bind to the `favoriteFramework` property.
5252

53-
<docs-code language="html" highlight="[3]">
53+
```html {highlight:[3]}
5454
<label for="framework">
5555
Favorite Framework:
5656
<input id="framework" type="text" [(ngModel)]="favoriteFramework" />
5757
</label>
58-
</docs-code>
58+
```
5959

6060
After you've made changes, try entering a value in the input field. Notice how it updates on the screen (yes, very cool).
6161

adev/src/content/tutorials/learn-angular/steps/16-form-control-values/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In this activity, you'll learn how to get the value from your form input.
1414

1515
To display the input value in a template, you can use the interpolation syntax `{{}}` just like any other class property of the component:
1616

17-
<docs-code language="angular-ts" highlight="[5]">
17+
```angular-ts {highlight:[5]}
1818
@Component({
1919
selector: 'app-user',
2020
template: `
@@ -29,15 +29,15 @@ To display the input value in a template, you can use the interpolation syntax `
2929
export class User {
3030
favoriteFramework = '';
3131
}
32-
</docs-code>
32+
```
3333

3434
</docs-step>
3535

3636
<docs-step title="Retrieve the value of an input field">
3737

3838
When you need to reference the input field value in the component class, you can do so by accessing the class property with the `this` syntax.
3939

40-
<docs-code language="angular-ts" highlight="[15]">
40+
```angular-ts {highlight:[15]}
4141
...
4242
@Component({
4343
selector: 'app-user',
@@ -51,11 +51,11 @@ export class User {
5151
favoriteFramework = '';
5252
...
5353
54-
showFramework() {
55-
alert(this.favoriteFramework);
54+
showFramework() {
55+
alert(this.favoriteFramework);
56+
}
5657
}
57-
}
58-
</docs-code>
58+
```
5959

6060
</docs-step>
6161

0 commit comments

Comments
 (0)