Skip to content

Commit 69b13b3

Browse files
authored
feat(vue): add code highlighting (#4311)
1 parent c224da9 commit 69b13b3

21 files changed

+452
-346
lines changed

docs/vue/build-options.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Also note that locally registered components are not available in subcomponents.
2828

2929
Let's take a look at how local component registration works:
3030

31-
```html
31+
```vue
3232
<template>
3333
<ion-page>
3434
<ion-content>
@@ -38,8 +38,8 @@ Let's take a look at how local component registration works:
3838
</template>
3939
4040
<script setup lang="ts">
41-
import { IonContent, IonPage } from '@ionic/vue';
42-
import SubComponent from '@/components/SubComponent.vue';
41+
import { IonContent, IonPage } from '@ionic/vue';
42+
import SubComponent from '@/components/SubComponent.vue';
4343
</script>
4444
```
4545

@@ -70,7 +70,7 @@ app.component('ion-page', IonPage);
7070

7171
**MyComponent.vue**
7272

73-
```html
73+
```vue
7474
<template>
7575
<ion-page>
7676
<ion-content>
@@ -80,7 +80,7 @@ app.component('ion-page', IonPage);
8080
</template>
8181
8282
<script setup lang="ts">
83-
import SubComponent from '@/components/SubComponent.vue';
83+
import SubComponent from '@/components/SubComponent.vue';
8484
</script>
8585
```
8686

docs/vue/lifecycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ These lifecycles are only called on components directly mapped by a router. This
2121

2222
The lifecycles are defined the same way Vue lifecycle methods are - as functions at the root of your Vue component:
2323

24-
```tsx
24+
```vue
2525
<script setup lang="ts">
2626
import { IonPage } from '@ionic/vue';
2727
@@ -47,7 +47,7 @@ const ionViewWillLeave = () => {
4747

4848
These lifecycles can also be expressed using Vue 3's Composition API:
4949

50-
```tsx
50+
```vue
5151
<script setup lang="ts">
5252
import { IonPage, onIonViewWillEnter, onIonViewDidEnter, onIonViewWillLeave, onIonViewDidLeave } from '@ionic/vue';
5353

docs/vue/navigation.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Say we start on the `home` route, and we want to add a button that takes us to t
103103

104104
We can also programmatically navigate in our app by using the router API:
105105

106-
```html
106+
```vue
107107
<template>
108108
<ion-page>
109109
<ion-content>
@@ -113,10 +113,10 @@ We can also programmatically navigate in our app by using the router API:
113113
</template>
114114
115115
<script setup lang="ts">
116-
import { IonButton, IonContent, IonPage } from '@ionic/vue';
117-
import { useRouter } from 'vue-router';
116+
import { IonButton, IonContent, IonPage } from '@ionic/vue';
117+
import { useRouter } from 'vue-router';
118118
119-
const router = useRouter();
119+
const router = useRouter();
120120
</script>
121121
```
122122

@@ -364,7 +364,7 @@ Here, our `tabs` path loads a `Tabs` component. We provide each tab as a route o
364364

365365
Let's start by taking a look at our `Tabs` component:
366366

367-
```html
367+
```vue
368368
<template>
369369
<ion-page>
370370
<ion-tabs>
@@ -390,8 +390,8 @@ Let's start by taking a look at our `Tabs` component:
390390
</template>
391391
392392
<script setup lang="ts">
393-
import { IonTabBar, IonTabButton, IonTabs, IonLabel, IonIcon, IonPage, IonRouterOutlet } from '@ionic/vue';
394-
import { ellipse, square, triangle } from 'ionicons/icons';
393+
import { IonTabBar, IonTabButton, IonTabs, IonLabel, IonIcon, IonPage, IonRouterOutlet } from '@ionic/vue';
394+
import { ellipse, square, triangle } from 'ionicons/icons';
395395
</script>
396396
```
397397

@@ -494,7 +494,7 @@ Nothing should be provided inside of `IonRouterOutlet` when setting it up in you
494494

495495
The `IonPage` component wraps each view in an Ionic Vue app and allows page transitions and stack navigation to work properly. Each view that is navigated to using the router must include an `IonPage` component.
496496

497-
```html
497+
```vue
498498
<template>
499499
<ion-page>
500500
<ion-header>
@@ -507,7 +507,7 @@ The `IonPage` component wraps each view in an Ionic Vue app and allows page tran
507507
</template>
508508
509509
<script setup lang="ts">
510-
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
510+
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
511511
</script>
512512
```
513513

@@ -550,7 +550,7 @@ Notice that we have now added `:id` to the end of our `detail` path string. URL
550550

551551
Let's look at how to use it in our component:
552552

553-
```html
553+
```vue
554554
<template>
555555
<ion-page>
556556
<ion-header>
@@ -564,11 +564,11 @@ Let's look at how to use it in our component:
564564
</template>
565565
566566
<script setup lang="ts">
567-
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
568-
import { useRoute } from 'vue-router';
567+
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
568+
import { useRoute } from 'vue-router';
569569
570-
const route = useRoute();
571-
const { id } = route.params;
570+
const route = useRoute();
571+
const { id } = route.params;
572572
</script>
573573
```
574574

docs/vue/performance.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ When using `v-for` with Ionic components, we recommend using Vue's `key` attribu
1111

1212
By using `key` you can provide a stable identity for each loop element so Vue can track insertions and deletions within the iterator. Below is an example of how to use `key`:
1313

14-
```html
14+
```vue
1515
<template>
1616
<ion-page>
1717
<ion-content>
@@ -23,14 +23,14 @@ By using `key` you can provide a stable identity for each loop element so Vue ca
2323
</template>
2424
2525
<script setup lang="ts">
26-
import { IonContent, IonItem, IonLabel, IonPage } from '@ionic/vue';
27-
import { ref } from 'vue';
28-
29-
const items = ref([
30-
{ id: 0, value: 'Item 0' },
31-
{ id: 1, value: 'Item 1' },
32-
...
33-
]);
26+
import { IonContent, IonItem, IonLabel, IonPage } from '@ionic/vue';
27+
import { ref } from 'vue';
28+
29+
const items = ref([
30+
{ id: 0, value: 'Item 0' },
31+
{ id: 1, value: 'Item 1' },
32+
...
33+
]);
3434
</script>
3535
```
3636

docs/vue/quickstart.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Let's walk through these files to understand the app's structure.
7474

7575
The root of your app is defined in `App.vue`:
7676

77-
```tsx
77+
```vue
7878
<template>
7979
<ion-app>
8080
<ion-router-outlet />
@@ -123,7 +123,7 @@ When you visit the root URL (`/`), the `HomePage` component will be loaded.
123123

124124
The Home page component, defined in `views/HomePage.vue`, imports the Ionic components and defines the page template:
125125

126-
```html
126+
```vue
127127
<template>
128128
<ion-page>
129129
<ion-header :translucent="true">
@@ -153,7 +153,7 @@ The Home page component, defined in `views/HomePage.vue`, imports the Ionic comp
153153
</template>
154154
155155
<script setup lang="ts">
156-
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
156+
import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
157157
</script>
158158
159159
<!-- ...styles... -->
@@ -169,7 +169,7 @@ For detailed information about Ionic layout components, see the [Header](/docs/a
169169

170170
You can enhance your Home page with more Ionic UI components. For example, add a [Button](/docs/api/button) at the end of the `ion-content`:
171171

172-
```html
172+
```vue
173173
<ion-content>
174174
<!-- existing content -->
175175
@@ -179,17 +179,17 @@ You can enhance your Home page with more Ionic UI components. For example, add a
179179

180180
Then, import the `IonButton` component in the `<script>` tag:
181181

182-
```html
182+
```vue
183183
<script setup lang="ts">
184-
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
184+
import { IonButton, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
185185
</script>
186186
```
187187

188188
## Add a New Page
189189

190190
Create a new page at `views/NewPage.vue`:
191191

192-
```html
192+
```vue
193193
<template>
194194
<ion-page>
195195
<ion-header :translucent="true">
@@ -212,7 +212,7 @@ Create a new page at `views/NewPage.vue`:
212212
</template>
213213
214214
<script setup lang="ts">
215-
import { IonBackButton, IonButtons, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
215+
import { IonBackButton, IonButtons, IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
216216
</script>
217217
```
218218

@@ -255,7 +255,7 @@ const routes: Array<RouteRecordRaw> = [
255255

256256
Once that is done, update the button in `views/HomePage.vue`:
257257

258-
```tsx
258+
```vue
259259
<ion-button router-link="/new">Navigate</ion-button>
260260
```
261261

@@ -269,16 +269,16 @@ Ionic Vue comes with [Ionicons](https://ionic.io/ionicons/) pre-installed. You c
269269

270270
Update the imports in `views/NewPage.vue` to import `IonIcon` and the `heart` and `logoIonic` icons:
271271

272-
```html
272+
```vue
273273
<script setup lang="ts">
274-
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
275-
import { heart, logoIonic } from 'ionicons/icons';
274+
import { IonBackButton, IonButtons, IonContent, IonHeader, IonIcon, IonPage, IonTitle, IonToolbar } from '@ionic/vue';
275+
import { heart, logoIonic } from 'ionicons/icons';
276276
</script>
277277
```
278278

279279
Then, include them inside of the `ion-content`:
280280

281-
```tsx
281+
```vue
282282
<ion-icon :icon="heart"></ion-icon>
283283
<ion-icon :icon="logoIonic"></ion-icon>
284284
```
@@ -293,7 +293,7 @@ Let's add a button that can scroll the content area to the bottom.
293293

294294
Update `views/NewPage.vue` to include a ref on `ion-content` and a button and some items after the existing icons:
295295

296-
```html
296+
```vue
297297
<ion-content ref="content">
298298
<ion-button @click="scrollToBottom">Scroll to Bottom</ion-button>
299299
@@ -306,29 +306,29 @@ Update `views/NewPage.vue` to include a ref on `ion-content` and a button and so
306306

307307
In the script section, add the new component imports and define the `scrollToBottom` function:
308308

309-
```html
309+
```vue
310310
<script setup lang="ts">
311-
import {
312-
IonBackButton,
313-
IonButtons,
314-
IonButton,
315-
IonContent,
316-
IonHeader,
317-
IonIcon,
318-
IonItem,
319-
IonLabel,
320-
IonPage,
321-
IonTitle,
322-
IonToolbar,
323-
} from '@ionic/vue';
324-
import { heart, logoIonic } from 'ionicons/icons';
325-
import { ref } from 'vue';
326-
327-
const content = ref();
328-
329-
const scrollToBottom = () => {
330-
content.value.$el.scrollToBottom(300);
331-
};
311+
import {
312+
IonBackButton,
313+
IonButtons,
314+
IonButton,
315+
IonContent,
316+
IonHeader,
317+
IonIcon,
318+
IonItem,
319+
IonLabel,
320+
IonPage,
321+
IonTitle,
322+
IonToolbar,
323+
} from '@ionic/vue';
324+
import { heart, logoIonic } from 'ionicons/icons';
325+
import { ref } from 'vue';
326+
327+
const content = ref();
328+
329+
const scrollToBottom = () => {
330+
content.value.$el.scrollToBottom(300);
331+
};
332332
</script>
333333
```
334334

0 commit comments

Comments
 (0)