Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import .md file from index.js children doesnot work #58

Open
5 tasks done
hualayn opened this issue Dec 27, 2024 · 0 comments
Open
5 tasks done

import .md file from index.js children doesnot work #58

hualayn opened this issue Dec 27, 2024 · 0 comments

Comments

@hualayn
Copy link

hualayn commented Dec 27, 2024

Describe the bug

when i import the .md file in the component of children section like below, it doesnot work.
otherwise in the parent component it works well.
pls help me with this problem and how to do to make it work in the children section

// index.js
import { createRouter, createWebHistory } from 'vue-router'
import MyView from '../views/MyView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: MyView,
    },
    {
      path: '/one',
      component: () => import('../pages/one.md'),
      children: [
        {
          path: 'sub-a',
          component: () => import("../pages/one-sub-a.md")
        },
        {
          path: 'sub-b',
          component: () => import("../pages/one-sub-b.md")
        }
      ]
    },
    {
      path: '/two',
      component: () => import('../pages/two.md')
    },
  ],
})

export default router
// App.vue
<template>
  <nav>
    <RouterLink to="/">home</RouterLink>|
    <RouterLink to="/one">one</RouterLink>|
    <RouterLink to="/two">two</RouterLink>|
    <RouterLink to="/one/sub-a">one-sub-a</RouterLink>|
    <RouterLink to="/one/sub-b">one-sub-b</RouterLink>
  </nav>
  <br />
  <div>
    <RouterView />
  </div>  
</template>
// vite.config.js
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import Markdown from 'unplugin-vue-markdown/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      include: [/\.vue$/, /\.md$/], // <-- allows Vue to compile Markdown files
    }),
    vueDevTools(),
    Markdown()
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})

Reproduction

https://github.com/hualayn/unplugin-vue-markdown-test

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (4) x64 Intel(R) Core(TM) i3-7100 CPU @ 3.90GHz
    Memory: 6.23 GB / 15.88 GB
  Binaries:
    Node: 22.11.0 - ~\AppData\Local\fnm_multishells\7424_1735279886876\node.EXE
    npm: 11.0.0 - ~\AppData\Local\fnm_multishells\7424_1735279886876\npm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.79)

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant