Skip to content

Commit 78d4b15

Browse files
author
Christopher Mühl
committed
Add preview to Readme
1 parent 6a0c041 commit 78d4b15

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preview.gif

README.md

+32-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
1-
# `vuepress-plugin-code-switcher`
1+
# vuepress-plugin-code-switcher
2+
Component that allows having synchronized language switchable code blocks (e.g. to switch between Java and Kotlin examples). Selected languages are persisted to local storage to have language selection be permanent across page requests.
23

3-
### Installation
4-
Install `vuepress-plugin-code-switcher` as a dependency and add it to your config's plugin list:
4+
## Demo
5+
![](preview.gif)
6+
7+
## Installation
8+
```
9+
$ npm install vuepress-plugin-code-switcher --save
10+
```
11+
12+
After installing, add it to your Vuepress configuration's plugin list:
513

614
```js
715
module.exports = {
816
plugins: [ 'code-switcher' ]
917
}
1018
```
1119

12-
### Example
13-
```markdown
20+
### Usage
21+
````markdown
1422
<CodeSwitcher :languages="{js:'JavaScript',ts:'TypeScript'}">
1523
<template v-slot:js>
1624

17-
```js
18-
module.exports = function (str) {
19-
return typeof str === 'string' && str.trim() === str
20-
}
21-
```
25+
```js
26+
module.exports = function (str) {
27+
return typeof str === 'string' && str.trim() === str
28+
}
29+
```
2230

2331
</template>
2432
<template v-slot:ts>
2533

26-
```ts
27-
export default function isString (str: string) : str is string {
28-
return typeof str === 'string' && str.trim() === str
29-
}
30-
```
34+
```ts
35+
export default function isString (str: string) : str is string {
36+
return typeof str === 'string' && str.trim() === str
37+
}
38+
```
3139

3240
</template>
3341
</CodeSwitcher>
34-
```
42+
````
43+
44+
> The extra newline between the `<template>` tags and their content is necessary if you want to have Markdown interpreted within the component.
3545
36-
The extra newline between the `<template>` tags and their content is necessary if you want to have Markdown interpreted within the component.
46+
#### Props
47+
| Prop | Description | Type | Default |
48+
| ----- | ----- | ---- | ---- |
49+
| languages | The languages that can be switched between. The object expects shorthands as keys and the tab title as values. The shorthands will also be used as slot names | Object | --- |
50+
| name | All code switchers on one page with the same name will be synchronized | String | `'default'` |
51+
| isolated | if true, this block will not synchronize with any others or load/save its state to/from localstorage | Boolean | `false` |

preview.gif

1.77 MB
Loading

0 commit comments

Comments
 (0)