├── .eslintrc.js
├── .gitignore
├── .npmignore
├── .prettierrc.js
├── LICENSE
├── README.md
├── index.html
├── package-lock.json
├── package.json
├── public
└── favicon.ico
├── src
├── components
│ └── markvue.vue
├── demo
│ ├── App.vue
│ ├── content.ts
│ ├── main.ts
│ └── stubTest.vue
├── env.d.ts
├── index.ts
└── utils
│ ├── compiler.ts
│ ├── nanoid.ts
│ └── parser.ts
├── tsconfig.json
└── vite.config.ts
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: 'vue-eslint-parser',
3 | parserOptions: {
4 | parser: '@typescript-eslint/parser',
5 | ecmaVersion: 2020,
6 | sourceType: 'module',
7 | },
8 | extends: ['alloy', 'alloy/typescript', 'alloy/vue', 'plugin:vue/vue3-essential', 'prettier'],
9 | rules: {
10 | 'vue/no-v-model-argument': 0,
11 | 'vue/multi-word-component-names': 0,
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .DS_Store
3 | dist
4 | dist-ssr
5 | *.local
6 | .history
7 | .vscode
8 | lib
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .git
2 | public
3 | index.html
4 | .vscode
5 | .history
6 | .prettierrc.js
7 | tsconfig.json
8 | vite.config.ts
9 | .eslintrc.js
10 | .eslintignore
11 | /src
12 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | printWidth: 120,
3 | tabWidth: 2,
4 | semi: true,
5 | singleQuote: true,
6 | trailingComma: 'all',
7 | arrowParens: 'always',
8 | };
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 BackRunner
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MarkVue
2 |
3 | Allows you to mix Vue component or Vue SFC into Markdown, inspired by `@vue/sfc-playground`.
4 |
5 | ## How to use
6 |
7 | 1: Install the package:
8 |
9 | ```bash
10 | npm install markvue --save
11 | ```
12 |
13 | 2: Import it to your project:
14 |
15 | ```js
16 | import MarkVue from 'markvue';
17 | import { createApp } from 'vue';
18 | import App from './app.vue';
19 |
20 | const app = createApp(App);
21 | app.use(MarkVue);
22 |
23 | app.mount('#app');
24 | ```
25 |
26 | Our component only support Vue 3, Vue 2 is not supported.
27 |
28 | 3: Use it in your pages:
29 |
30 | ```vue
31 |
32 |
33 |
34 |
35 |
56 |
65 |
66 |
67 |
68 |
69 |
70 | second sfc
71 |
72 |
73 |
74 |
75 | Here's a vue component stub.
76 |
77 |
78 | `
79 | export default defineComponent({
80 | setup() {
81 | return {
82 | content,
83 | };
84 | },
85 | });
86 |
87 | ```
88 |
89 | For Vue SFC, markvue will inject Vue into the SFC as `context`, you can import APIs from Vue directly.
90 |
91 | If you want to import something from other package, be sure to put it in the `context`, and bind it to markvue, just like this:
92 |
93 | ```vue
94 |
95 |
96 |
97 |
98 |
114 |
115 | `,
116 | context: {
117 | SOME_PACKAGE: SOMETHING,
118 | },
119 | };
120 |
121 | ```
122 |
123 | You can also put a Vue component into `context` directly, you can mix it into your Markdown like this:
124 |
125 | ```markdown
126 | # Title
127 |
128 | content
129 |
130 |
131 | ```
132 |
133 | ```vue
134 |
135 |
136 |
137 |
138 |
147 | ```
148 |
149 | If you want to add `class` or some other attribute in the root element of Vue SFC or Vue component, you can just add it to the `` or `` tag, like this:
150 |
151 | ```Markdown
152 |
153 |
154 | or
155 |
156 |
157 |
158 | ```
159 |
160 | For custom options of `marked`, you can set an attribute `markedOptions` to `markvue`, like this:
161 |
162 | ```vue
163 |
164 |
165 |
166 | ```
167 |
168 | ## Features
169 |
170 | Supported SFC Features:
171 |
172 | - `
10 |
11 |
12 |
13 |
14 |
15 |