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

It seems doesn't work will with .jsx file. #145

Open
whoooami opened this issue Feb 13, 2024 · 1 comment
Open

It seems doesn't work will with .jsx file. #145

whoooami opened this issue Feb 13, 2024 · 1 comment
Assignees

Comments

@whoooami
Copy link

whoooami commented Feb 13, 2024

I add three [home, default, 404] in src/layouts use jsx.
1、 vite.config.ts

    Layouts({
      extensions: ['vue', 'jsx'],
    }),

2、add layout yaml config

import { defineComponent } from 'vue'

export default defineComponent({
  setup() {
    const { t } = useI18n()
    // eslint-disable-next-line unused-imports/no-unused-vars
    const route = useRoute()

    return () => (
      <>
        <div>
          Test layout
        </div>
        <route lang="yaml">
        meta:
          layout: home
        </route>
      </>
    )
  },
})

But it always use default layout when file name is index.jsx. when I change back to index.vue. It works with meta layout.

@markthree
Copy link
Collaborator

markthree commented Feb 16, 2024

@whoooami Because the custom block only applies to the SFCjsx is so dynamic that parsing it is difficult, and in most cases the only way to know what's going on inside is to run it.

However, vite-plugin-vue-layout needs to get the meta of the corresponding page routes before running

@markthree markthree self-assigned this Feb 16, 2024
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

2 participants