You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/docs/docs/theme/default-theme-config.md
+84
Original file line number
Diff line number
Diff line change
@@ -557,6 +557,90 @@ layout: SpecialLayout
557
557
558
558
This will render `.vuepress/components/SpecialLayout.vue` for the given page.
559
559
560
+
## Code Groups and Code Blocks <Badgetext="1.6.0+" />
561
+
The default theme comes with custom components `<code-group />` and `<code-block>` that can help you to better group
562
+
separate code paths that have the same result.
563
+
564
+
**Example**
565
+
566
+
Yarn and npm installation instructions
567
+
568
+
**Input**
569
+
````md
570
+
<code-group>
571
+
<code-block title="YARN">
572
+
```bash
573
+
yarn create vuepress-site [optionalDirectoryName]
574
+
```
575
+
</code-block>
576
+
577
+
<code-block title="NPM">
578
+
```bash
579
+
npx create-vuepress-site [optionalDirectoryName]
580
+
```
581
+
</code-block>
582
+
</code-group>
583
+
````
584
+
585
+
**Output**
586
+
587
+
<code-group>
588
+
<code-blocktitle="YARN">
589
+
```bash
590
+
yarn create vuepress-site [optionalDirectoryName]
591
+
```
592
+
</code-block>
593
+
594
+
<code-blocktitle="NPM">
595
+
```bash
596
+
npx create-vuepress-site [optionalDirectoryName]
597
+
```
598
+
</code-block>
599
+
</code-group>
600
+
601
+
::: tip
602
+
Each `<code-block />` must have a line break after it to render properly
603
+
:::
604
+
605
+
### Default Code Block
606
+
607
+
By default, `<code-group />` will use the first `<code-block />` as the active initial code block.
608
+
609
+
To manually set the active `<code-block />`, just add the `active` prop to the `<code-block />`:
610
+
611
+
**Input**
612
+
````md
613
+
<code-group>
614
+
<code-block title="YARN">
615
+
```bash
616
+
yarn create vuepress-site [optionalDirectoryName]
617
+
```
618
+
</code-block>
619
+
620
+
<code-block title="NPM" active>
621
+
```bash
622
+
npx create-vuepress-site [optionalDirectoryName]
623
+
```
624
+
</code-block>
625
+
</code-group>
626
+
````
627
+
628
+
**Output**
629
+
630
+
<code-group>
631
+
<code-blocktitle="YARN">
632
+
```bash
633
+
yarn create vuepress-site [optionalDirectoryName]
634
+
```
635
+
</code-block>
636
+
637
+
<code-blocktitle="NPM"active>
638
+
```bash
639
+
npx create-vuepress-site [optionalDirectoryName]
640
+
```
641
+
</code-block>
642
+
</code-group>
643
+
560
644
## Ejecting
561
645
562
646
You can copy the default theme source code into `.vuepress/theme` to fully customize the theme using the `vuepress eject [targetDir]` command. If you didn’t install VuePress globally, run `./node_modules/.bin/vuepress eject`.
0 commit comments