From 549f6b640c653c2f9376f9261edd8341559ce76d Mon Sep 17 00:00:00 2001 From: "@andatoshiki" Date: Sun, 17 Sep 2023 02:14:12 -0700 Subject: [PATCH] fix: removed unnessary & redundant transformation replacement options for markdowns that causes unexpected vite wepacking behaviors such as `whitespaces` and `unrecongized import of assets --- docs/.vitepress/plugins/markdownTransform.ts | 41 +++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/docs/.vitepress/plugins/markdownTransform.ts b/docs/.vitepress/plugins/markdownTransform.ts index cd5c88cf..f52e049e 100644 --- a/docs/.vitepress/plugins/markdownTransform.ts +++ b/docs/.vitepress/plugins/markdownTransform.ts @@ -1,6 +1,6 @@ import type { Plugin } from 'vite' -import { replacer } from '../../../scripts/markdownTransform' import { getReadingTime } from './../theme/utils' +// import { replacer } from '../../../scripts/utils' export function MarkdownTransform(): Plugin { return { @@ -9,7 +9,7 @@ export function MarkdownTransform(): Plugin { async transform(code, id) { if (!id.match(/\.md\b/)) return null // convert links to relative - code = code.replace(/https?:\/\/toshiki-notebook\.dev\//g, '/') + code = code.replace(/https?:\/\/note.toshiki\.dev\//g, '/') const [_name, i] = id.split('/').slice(-2) // convert img by applying regex @@ -25,19 +25,22 @@ export function MarkdownTransform(): Plugin { // } // convert links to components - const linkRegex = /\[(.+?)\]\((.+?)\)/g - let matches = linkRegex.exec(code) - while (matches) { - const [text, link] = matches.slice(1) - code = code.replace(matches[0], ``) - matches = linkRegex.exec(code) - } + // const linkRegex = /\[(.+?)\]\((.+?)\)/g; + // let matches = linkRegex.exec(code); + // while (matches) { + // const [text, link] = matches.slice(1); + // code = code.replace( + // matches[0], + // `` + // ); + // matches = linkRegex.exec(code); + // } // cut index.md if (_name === 'docs' && i === 'index.md') return code - const { footer } = await getDocsMarkdown() - code = replacer(code, footer, 'FOOTER', 'tail') + // const { footer } = await getDocsMarkdown() + // code = replacer(code, footer, 'FOOTER', 'tail') const { readTime, words } = getReadingTime(code) code = code.replace(/(#\s.+?\n)/, `$1\n\n\n`) @@ -46,13 +49,13 @@ export function MarkdownTransform(): Plugin { } } -export async function getDocsMarkdown() { - const CopyRightSection = ` - ` +// export async function getDocsMarkdown() { +// const CopyRightSection = ` +// `; - const footer = `${CopyRightSection}\n` +// const footer = `${CopyRightSection}\n`; - return { - footer, - } -} +// return { +// footer, +// }; +// }