Comments (12)
I absolutely want to support Vuepress 2. I tried my hands at it a while ago, but did hit a few walls with the plugin api at the time. Until I get to this, if anyone seeing this issue wants to make an attempt I'm more than happy to help polish it for merging. (please don't read this as me not wanting to do the work, I just want to point out that contributions are welcome.)
from vuepress-plugin-mermaidjs.
I (finally, sorry), just released v2.0.0-beta.1 with Vuepress 2 support. Please don't hesitate to open new issues regarding broken things/missing features. I'll close this one though as it only pertains to general support.
from vuepress-plugin-mermaidjs.
For those who need to use Mermaid in Vuepress 2 before this plugin starts to support it can do it this hacky way:
- Install Mermaid:
npm install mermaid
- If you haven't added support for custom Vue components yet, do that:
npm install @vuepress/plugin-register-components
.- In the
config.js
file, add the plugin in theplugins
section with (for example) code like:
[
"@vuepress/register-components",
{
componentsDir: path.resolve(__dirname, './components'),
},
]
- Create a new Vue component in your components folder called
mermaid.vue
. Use the following code for it:
<template>
<div class="mermaid">
<slot></slot>
</div>
</template>
<script>
export default {
mounted() {
import("mermaid/dist/mermaid").then(m => {
m.initialize({
startOnLoad: true
});
m.init()
})
}
}
</script>
Then you can use Mermaid in your markdown files this hacky way:
Testing
<mermaid>
{{`
graph LR
users["Users"]
subgraph "Users' computers"
webBrowser["Web Browser"]
end
subgraph "Web Server"
webApp["Web Application"]
end
subgraph "Database Server"
db["Database"]
end
users -- Use --> webBrowser
webBrowser -- HTTP --> webApp
webApp -- SQL --> db
`}}
</mermaid>
Testing
When this plugin supports Vuepress 2 it's of course much better to use Mermaid through this plugin.
from vuepress-plugin-mermaidjs.
(Crossposting this for easier reference from #78)
While I want to support VuePress 2/next, I also want to keep supporting Vuepress 1.x for the time being. Unfortunately, these requirements are largely mutually exclusive on because of the massive changes in Vue 3 and the new VuePress plugin API. I'm still torn on whether to go the lerna monorepository route and publish vuepress-plugin-mermaidjs
and e.g. vuepress2-plugin-mermaidjs
side by side or whether "clever branching" might be a way to go. After all, the only dependency to be kept up to date on the VuePress 1.x branch would be Mermaid. Then this Library could make a major version jump and be 1.x for VuePress 1 and 2.x and onwards for VuePress 2.
from vuepress-plugin-mermaidjs.
@eFrane This is still a work in progress, I have a preliminary V2 plugin working here if you are interested. https://gitlab.com/sloud/vuepress-plugin-default-theme-mermaid
from vuepress-plugin-mermaidjs.
So, turns out I'm going to have to basically rewrite this Plugin because the Vue 3/Vuepress 2 combo feels very much like Angular 2 all over again. Anyone wanting to chip in ideas on how long I should maintain a Vuepress 1 version is welcome to do so. :)
from vuepress-plugin-mermaidjs.
@eFrane I don't have much experience of maintaining two versions like that in parallel, but I think I would go with a single repo. If I'm not mistaking, I think the official VuePress 2 plugins use that strategy; in package.json
for my app using VuePress 2 I have:
"@vuepress/plugin-git": "^2.0.0-alpha.1",
"@vuepress/plugin-register-components": "^2.0.0-beta.24",
from vuepress-plugin-mermaidjs.
@jeremycloud This looks awesome. Would you be okay with me borrowing (with attribution of course) a little bit from your work?
from vuepress-plugin-mermaidjs.
@eFrane yeah go for it.
from vuepress-plugin-mermaidjs.
@eFrane does not really work for me:
Error: Cannot find module '@vuepress/shared-utils'
Require stack:
- [...]\node_modules\vuepress-plugin-mermaidjs\src\markdownItPlugin.js
my package.json
"devDependencies": {
"@vuepress/plugin-search": "^2.0.0-beta.37",
"vuepress": "^2.0.0-beta.37",
"vuepress-plugin-mermaidjs": "^2.0.0-beta.2"
}
I assume a CI would've seen this. Maybe you should fix Travis as well?
from vuepress-plugin-mermaidjs.
Also the source code does not work on windows (at least for me):
npx vuepress build docs
causes the file docs/.vuepress/.temp/internal/clientAppEnhancements.js
to be built. Sadly this file contains an invalid path (Windows backslash dilemma):
// other imports
import clientAppEnhance3 from 'D:/projekte/github/vuepress-plugin-mermaidjs/node_modules/@vuepress/theme-default/lib/client/clientAppEnhance.js'
import clientAppEnhance4 from 'D:\projekte\github\vuepress-plugin-mermaidjs\src\clientAppEnhance.js'
Maybe this is a vite bug. I don't know. Just wanted to mention it. The dirty fix is:
clientAppEnhanceFiles: path.resolve(__dirname, 'clientAppEnhance.js').replace(/\\/g, '/')
in src/index.js
from vuepress-plugin-mermaidjs.
I wrote a patch for latest VuePress 2 beta (as of now 2.0.0-beta.51): https://github.com/v2fly/v2fly-github-io/blob/991b634231afb5957fc1eef198b8b9e0f92f571e/patches/vuepress-plugin-mermaidjs%2B2.0.0-beta.2.patch
from vuepress-plugin-mermaidjs.
Related Issues (20)
- Add support for custom diagram styles via diagram comments
- Doesn't work with vuepress 2
- Error in hook extendsMarkdown on Vuepress 2 for [email protected] HOT 1
- gitGraph doesn't work
- Diagrams not created if built inside docker container HOT 4
- Missing dependencies HOT 3
- npm WARN deprecated @braintree/[email protected]: Potential XSS vulnerability patched in v6.0.0.
- The generated svg size doesn't match the mobile device HOT 2
- Not compatible with VuePress 2.0.0-beta.51
- Make mermaid a peer dependency so it can easily be upgraded HOT 2
- More graphs HOT 3
- [Feature Request] Add a class name to the "div" that wraps the mermaid diagram HOT 1
- Plugin not working after `vuepress build` HOT 2
- Fullscreen mode HOT 3
- Click events on graph elements are not working HOT 2
- Are there plans to support VuePress 2.x ? HOT 1
- Cypress Tests are inconsistent HOT 1
- Duplicated code blocks HOT 4
- extra large margin around diagram. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuepress-plugin-mermaidjs.