# Vue 2 Quick Start Get started with markstream-vue2 in your Vue 2 project. ## Basic Setup ### 1. Installation First, install the package: ```bash pnpm add markstream-vue2 ``` ### 2. Import Styles In your main entry file (e.g., `main.js` or `main.ts`): ```js import Vue from 'vue' import App from './App.vue' import 'markstream-vue2/index.css' // For Vue 2.6.x, also install and configure @vue/composition-api // import VueCompositionAPI from '@vue/composition-api' // Vue.use(VueCompositionAPI) new Vue({ render: h => h(App) }).$mount('#app') ``` ### 3. Use the Component ```vue ``` ## Using with Vue 2.7+ (Composition API) Vue 2.7 includes built-in Composition API support: ```vue ``` ## Using with Vue 2.6.x (@vue/composition-api) For Vue 2.6.x, install `@vue/composition-api`: ```bash pnpm add @vue/composition-api ``` ```js import VueCompositionAPI from '@vue/composition-api' // main.js import Vue from 'vue' import 'markstream-vue2/index.css' Vue.use(VueCompositionAPI) ``` Then use it the same way as Vue 2.7: ```vue ``` ## Enabling Optional Features ### Code Syntax Highlighting Install dependencies: ```bash pnpm add stream-markdown ``` ```vue ``` ### Mermaid Diagrams Install mermaid: ```bash pnpm add mermaid ``` Import styles. The loader is enabled by default; call `enableMermaid()` only if you disabled it or need a custom loader: ```js import { enableMermaid } from 'markstream-vue2' // main.js import 'markstream-vue2/index.css' // optional: re-enable or override loader enableMermaid() ``` ```vue ``` ### D2 Diagrams Install D2: ```bash pnpm add @terrastruct/d2 ``` Import styles. The loader is enabled by default; call `enableD2()` only if you disabled it or need a custom loader: ```js import { enableD2 } from 'markstream-vue2' // main.js import 'markstream-vue2/index.css' // optional: re-enable or override loader enableD2() ``` ```vue ``` ### Math Formulas (KaTeX) Install katex: ```bash pnpm add katex ``` Import styles. The loader is enabled by default; call `enableKatex()` only if you disabled it or need a custom loader: ```js import { enableKatex } from 'markstream-vue2' // main.js import 'markstream-vue2/index.css' import 'katex/dist/katex.min.css' // optional: re-enable or override loader enableKatex() ``` ```vue ``` ## Custom Components You can customize how specific nodes are rendered using `setCustomComponents`: ```vue ``` ## Streaming Content markstream-vue2 supports streaming markdown content, which is useful for AI-generated content: ```vue ``` ## VitePress Integration (Vue 2) For VitePress with Vue 2, you can use markstream-vue2 in your custom theme: ```js import MarkdownRender, { setCustomComponents } from 'markstream-vue2' // docs/.vitepress/theme/index.js import DefaultTheme from 'vitepress/theme' import 'markstream-vue2/index.css' export default { extends: DefaultTheme, enhanceApp({ app }) { // Register the component globally app.component('MarkdownRender', MarkdownRender) // Set custom components if needed setCustomComponents('vitepress', { // Your custom components here }) } } ``` ## Next Steps - Explore [Components documentation](/guide/vue2-components) for all available components - Check out [API Reference](/guide/api) for detailed API documentation - See [Examples](/guide/examples) for more usage examples