emersonbottero / vitepress-plugin-mermaid

Add mermaid support for Vitepress
MIT License
87 stars 20 forks source link

fix: support user config self alias with array type #57

Closed scattter closed 1 year ago

scattter commented 1 year ago

now version doesn't support array type in alias config just object type, this commit can support user use array type. An example in here: https://github.com/emersonbottero/vitepress-plugin-mermaid/issues/56

Red-Asuka commented 1 year ago

@emersonbottero Hello, I found this issue during testing on the latest version v2.0.14. Is this modification not included in the latest version yet?

Red-Asuka commented 1 year ago

@emersonbottero The find property of alias may be a RegExp, in this case, it cannot be converted to an object and will display an error: Type 'RegExp' cannot be used as an index type.

For example, when we need to replace a component of the default theme:

alias: [
  {
    find: /^.*\/VPHero\.vue$/,
    replacement: fileURLToPath(
      new URL('../theme/components/Hero.vue', import.meta.url),
    ),
  },
]
Red-Asuka commented 1 year ago

@emersonbottero The find property of alias may be a RegExp, in this case, it cannot be converted to an object and will display an error: Type 'RegExp' cannot be used as an index type.

For example, when we need to replace a component of the default theme:

alias: [
  {
    find: /^.*\/VPHero\.vue$/,
    replacement: fileURLToPath(
      new URL('../theme/components/Hero.vue', import.meta.url),
    ),
  },
]

I create a PR to fix this issue: https://github.com/emersonbottero/vitepress-plugin-mermaid/pull/58