vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.49k stars 4.77k forks source link

Using import inside .md files in vuepress v2 #3038

Open cblaettl opened 2 years ago

cblaettl commented 2 years ago

Hello there,

First of all: thanks for creating and maintaining such a cool open-source documentation project! I really enjoyed working with vuepress v2 so far.

But now I'm struggling with the following:

I'd like to import a variable from clientAppEnhance.ts inside myArticle.md. My file structure looks like this:

docs/
├── .vuepress/
│   └── clientAppEnhance.ts
└── guide/
    └── myArticle.md

I tried the following inside myArticle.md, which doesn't work:


<script setup>
  import { myVar } from '../.vuepress/clientAppEnhance'

  // do something with myVar

</script>

Error message:

Failed to resolve import "../.vuepress/clientAppEnhance" from "docs/.vuepress/.temp/pages/guide/myArticle.html.vue". 
Does the file exist?

Is there a way to achieve this? Maybe by using or defining some path alias? I've looked up and down all documentation pages but couldn't find anything…

Thanks for any hint and answers. ❤️

Mister-Hope commented 2 years ago

This is VuePress 1 repo, please ensure you are using correct version and reading correct docs, VuePress 2 repo are at VuePress/VuePress-next