From 8e7dd1d14883a438cf090a12750b72d4d89af4b5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 19 Dec 2022 13:29:09 +0530 Subject: [PATCH 1/3] fix: Remove basepath from docs --- packages/mermaid/src/docs/.vitepress/config.ts | 4 ++-- packages/mermaid/src/docs/.vitepress/theme/index.ts | 2 +- packages/mermaid/src/docs/.vitepress/theme/redirect.ts | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index 216541d52..33e930cb8 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -14,9 +14,9 @@ export default defineConfig({ lang: 'en-US', title: 'Mermaid', description: 'Create diagrams and visualizations using text and code.', - base: '/mermaid/', + base: '/', markdown: allMarkdownTransformers, - head: [['link', { rel: 'icon', type: 'image/x-icon', href: '/mermaid/favicon.ico' }]], + head: [['link', { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]], themeConfig: { nav: nav(), editLink: { diff --git a/packages/mermaid/src/docs/.vitepress/theme/index.ts b/packages/mermaid/src/docs/.vitepress/theme/index.ts index efb065fea..ef929aa5d 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/index.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/index.ts @@ -18,7 +18,7 @@ export default { if (newPath) { console.log(`Redirecting to ${newPath} from ${window.location}`); // router.go isn't loading the ID properly. - window.location.href = `/mermaid/${newPath}`; + window.location.href = `/${newPath}`; } } catch (e) {} }; diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index ca4606be0..b6cfa4de2 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -10,7 +10,9 @@ export interface Redirect { const getBaseFile = (link: string): Redirect => { const url = new URL(link); if ( - (url.hostname !== 'mermaid-js.github.io' && url.hostname !== 'localhost') || + (url.hostname !== 'mermaid-js.github.io' && + url.hostname !== 'mermaid.js.org' && + url.hostname !== 'localhost') || url.pathname !== '/mermaid/' ) { throw new Error('Not mermaidjs url'); From fd5780d5a13aa583322105c5f70afdafe28e03d5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 19 Dec 2022 13:51:05 +0530 Subject: [PATCH 2/3] fix Redirect --- .../mermaid/src/docs/.vitepress/theme/redirect.spec.ts | 4 +--- packages/mermaid/src/docs/.vitepress/theme/redirect.ts | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts index c26364108..6070abee4 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.spec.ts @@ -8,6 +8,7 @@ test.each([ ['http://localhost:1234/mermaid/#/flowchart.md', 'syntax/flowchart.html'], ['http://localhost/mermaid/#/flowchart.md', 'syntax/flowchart.html'], ['https://mermaid-js.github.io/mermaid/#/flowchart.md', 'syntax/flowchart.html'], + ['https://mermaid.js.org/#/flowchart.md', 'syntax/flowchart.html'], ['https://mermaid-js.github.io/mermaid/#/./flowchart', 'syntax/flowchart.html'], ['https://mermaid-js.github.io/mermaid/#/flowchart', 'syntax/flowchart.html'], ['https://mermaid-js.github.io/mermaid/#flowchart', 'syntax/flowchart.html'], @@ -31,7 +32,4 @@ test.each([ test('should throw for invalid URL', () => { // Not mermaid domain expect(() => getRedirect('https://www.google.com')).toThrowError(); - - // Not `/mermaid/` path - expect(() => getRedirect('http://localhost/#/flowchart.md')).toThrowError(); }); diff --git a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts index b6cfa4de2..58537b0ef 100644 --- a/packages/mermaid/src/docs/.vitepress/theme/redirect.ts +++ b/packages/mermaid/src/docs/.vitepress/theme/redirect.ts @@ -10,10 +10,9 @@ export interface Redirect { const getBaseFile = (link: string): Redirect => { const url = new URL(link); if ( - (url.hostname !== 'mermaid-js.github.io' && - url.hostname !== 'mermaid.js.org' && - url.hostname !== 'localhost') || - url.pathname !== '/mermaid/' + url.hostname !== 'mermaid-js.github.io' && + url.hostname !== 'mermaid.js.org' && + url.hostname !== 'localhost' ) { throw new Error('Not mermaidjs url'); } From 81aee3554ea2caba457aa31cf1e93aca4c42b59c Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 19 Dec 2022 14:26:20 +0530 Subject: [PATCH 3/3] Revert "Add CNAME" This reverts commit 7670ada9acc552dcec0d6db53c8458c6d16df9ac. --- docs/CNAME | 1 - packages/mermaid/package.json | 2 +- packages/mermaid/src/docs/CNAME | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 docs/CNAME delete mode 100644 packages/mermaid/src/docs/CNAME diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 878812ee9..000000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -mermaid.js.org \ No newline at end of file diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index c3804896e..cd809fef1 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -28,7 +28,7 @@ "docs:build": "rimraf ../../docs && pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts", "docs:verify": "pnpm docs:spellcheck && pnpm docs:code && ts-node-esm src/docs.mts --verify", "docs:pre:vitepress": "rimraf src/vitepress && pnpm docs:code && ts-node-esm src/docs.mts --vitepress", - "docs:build:vitepress": "pnpm docs:pre:vitepress && vitepress build src/vitepress && cpy --flat src/docs/landing/ ./src/vitepress/.vitepress/dist/landing && cpy --flat src/docs/CNAME ./src/vitepress/.vitepress/dist/", + "docs:build:vitepress": "pnpm docs:pre:vitepress && vitepress build src/vitepress && cpy --flat src/docs/landing/ ./src/vitepress/.vitepress/dist/landing", "docs:dev": "pnpm docs:pre:vitepress && concurrently \"vitepress dev src/vitepress\" \"ts-node-esm src/docs.mts --watch --vitepress\"", "docs:serve": "pnpm docs:build:vitepress && vitepress serve src/vitepress", "docs:spellcheck": "cspell --config ../../cSpell.json \"src/docs/**/*.md\"", diff --git a/packages/mermaid/src/docs/CNAME b/packages/mermaid/src/docs/CNAME deleted file mode 100644 index 878812ee9..000000000 --- a/packages/mermaid/src/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -mermaid.js.org \ No newline at end of file