Skip to content

Commit c646656

Browse files
committed
docs: add vuepress doc
1 parent 1fc4cf0 commit c646656

File tree

6 files changed

+109
-2
lines changed

6 files changed

+109
-2
lines changed

docs/.vuepress/config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
title: 'Vue Mathjax',
3+
head: [
4+
['script', { src: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML' }]
5+
],
6+
themeConfig: {
7+
logo: '/logo.png',
8+
nav: [{ text: 'Guide', link: '/guide/quick-start' }],
9+
repo: 'https://github.com/justforuse/vue-mathjax',
10+
sidebar: [
11+
{
12+
title: 'Guide',
13+
collapsable: false,
14+
sidebarDepth: 0,
15+
children: ['/guide/quick-start']
16+
}
17+
]
18+
},
19+
plugins: [
20+
'demo-container'
21+
]
22+
}

docs/.vuepress/enhanceApp.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Mathjax from '../../packages'
2+
3+
export default ({ Vue, options, router }) => {
4+
Vue.use(Mathjax)
5+
}

docs/.vuepress/public/logo.png

43.1 KB
Loading

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
home: true
3+
heroImage: /logo.png
4+
heroText: Vue Mathjax
5+
tagline: A Vue plugin for mathjax
6+
actionText: Get Started →
7+
actionLink: /guide/quick-start
8+
---

docs/guide/quick-start.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Quick start
2+
3+
## Installation
4+
5+
```sh
6+
npm install --save vue-mathjax
7+
```
8+
9+
10+
## Usage
11+
### ❗️❗️Don't forget to import the Mathjax.js:
12+
```js
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS_HTML"></script>
14+
```
15+
16+
Import globally
17+
```js
18+
import VueMathjax from 'vue-mathjax'
19+
Vue.use(VueMathjax)
20+
```
21+
OR
22+
```js
23+
import {VueMathjax} from 'vue-mathjax'
24+
export default {
25+
...
26+
components: {
27+
'vue-mathjax': VueMathjax
28+
},
29+
...
30+
}
31+
```
32+
33+
## Demo
34+
35+
:::demo
36+
```html
37+
<div class="demo-container">
38+
<textarea v-model="formula" cols="30" rows="10"></textarea>
39+
<vue-mathjax :formula="formula"></vue-mathjax>
40+
</div>
41+
42+
<script>
43+
export default {
44+
name: 'HelloWorld',
45+
data () {
46+
return {
47+
formula: '$$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$'
48+
}
49+
}
50+
}
51+
</script>
52+
<style>
53+
.demo-container {
54+
text-align: center;
55+
}
56+
</style>
57+
```
58+
:::
59+
60+
## Props
61+
### formula
62+
`type: string` mathjax string
63+
64+
### safe
65+
`type: boolean; default: true` sometimes you want render the html in your mathjax, so just set it to false. demo: [codesandbox](https://codesandbox.io/s/vue-template-ftd5s)
66+
67+
### options
68+
`type: object; default: {}` custom Mathjax configurations

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"serve": "vue-cli-service serve",
1111
"build": "vue-cli-service build",
1212
"build:lib": "vue-cli-service build --target lib --name VueMathjax packages/index.js",
13-
"lint": "vue-cli-service lint"
13+
"lint": "vue-cli-service lint",
14+
"docs:dev": "vuepress dev docs",
15+
"docs:build": "vuepress build docs"
1416
},
1517
"dependencies": {
1618
"core-js": "^3.6.5",
@@ -31,7 +33,9 @@
3133
"babel-eslint": "^10.1.0",
3234
"eslint": "^6.7.2",
3335
"eslint-plugin-vue": "^6.2.2",
34-
"vue-template-compiler": "^2.6.11"
36+
"vue-template-compiler": "^2.6.11",
37+
"vuepress": "^1.9.7",
38+
"vuepress-plugin-demo-container": "^0.2.0"
3539
},
3640
"eslintConfig": {
3741
"root": true,

0 commit comments

Comments
 (0)