vuepress icon indicating copy to clipboard operation
vuepress copied to clipboard

Using import inside .md files in vuepress v2

Open cblaettl opened this issue 3 years ago β€’ 1 comments

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. ❀️

cblaettl avatar May 02 '22 09:05 cblaettl

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

Mister-Hope avatar Jun 18 '22 07:06 Mister-Hope