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