mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
docs: Add version to doc index.html
This commit is contained in:
parent
6029bdeee9
commit
bc258793ac
@ -49,7 +49,7 @@
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module">
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||
window.mermaid = mermaid;
|
||||
</script>
|
||||
<script>
|
||||
|
@ -41,7 +41,7 @@ import { remark } from 'remark';
|
||||
// @ts-ignore No typescript declaration file
|
||||
import flatmap from 'unist-util-flatmap';
|
||||
|
||||
const version = (
|
||||
const MERMAID_MAJOR_VERSION = (
|
||||
JSON.parse(readFileSync('packages/mermaid/package.json', 'utf8')).version as string
|
||||
).split('.')[0];
|
||||
|
||||
@ -148,7 +148,7 @@ const readSyncedUTF8file = (filename: string): string => {
|
||||
* @param file {string} name of the file that will be verified
|
||||
*/
|
||||
const transformMarkdown = (file: string) => {
|
||||
const doc = readSyncedUTF8file(file).replace(/<MERMAID_VERSION>/g, version);
|
||||
const doc = readSyncedUTF8file(file).replace(/<MERMAID_VERSION>/g, MERMAID_MAJOR_VERSION);
|
||||
const ast: Root = remark.parse(doc);
|
||||
const out = flatmap(ast, (c: Code) => {
|
||||
if (c.type !== 'code') {
|
||||
@ -189,7 +189,10 @@ const transformHtml = (filename: string) => {
|
||||
* @returns {string} The contents of the file with the comment inserted
|
||||
*/
|
||||
const insertAutoGeneratedComment = (fileName: string): string => {
|
||||
const fileContents = readSyncedUTF8file(fileName);
|
||||
const fileContents = readSyncedUTF8file(fileName).replace(
|
||||
/<MERMAID_VERSION>/g,
|
||||
MERMAID_MAJOR_VERSION
|
||||
);
|
||||
const jsdom = new JSDOM(fileContents);
|
||||
const htmlDoc = jsdom.window.document;
|
||||
const autoGeneratedComment = jsdom.window.document.createComment(AUTOGENERATED_TEXT);
|
||||
|
@ -49,7 +49,7 @@
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module">
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||
window.mermaid = mermaid;
|
||||
</script>
|
||||
<script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user