vite-plugin-vue-layouts icon indicating copy to clipboard operation
vite-plugin-vue-layouts copied to clipboard

not work with tsx

Open zcyc opened this issue 3 years ago • 2 comments

It dosn't render my layout, always render default layout. And render the meta tag text.

export default defineComponent({
  setup() {
    return () => <>
      <route lang="yaml">
        meta:
          layout: home
      </route>
    </>
  },
})

image

zcyc avatar Aug 05 '22 09:08 zcyc

Is this code equivalent to template effective

zhuhaobam avatar Aug 08 '22 09:08 zhuhaobam

无效的。vite-plugin-vue-layouts 不能用 tsx 中。

zcyc avatar Aug 19 '22 16:08 zcyc

I tried to change the layout by changing route.meta.layout, but it still does not work.

export default defineComponent({
  setup() {
    const route = useRoute()
    route.meta.layout = 'home'

    return () => (
      <>...</>
    )
  }
}

widcardw avatar Oct 02 '22 15:10 widcardw

https://github.com/hannoeru/vite-plugin-pages#jsxtsx-yaml-format-comments-for-route-datain-vue

Maybe we should turn to the docs of vite-plugin-pages.

widcardw avatar Oct 02 '22 16:10 widcardw

You can add a block comment in the JSX/TSX file like below

/*
route

meta:
  layout: home
*/

widcardw avatar Oct 05 '22 07:10 widcardw

You can add a block comment in the JSX/TSX file like below


/*

route



meta:

  layout: home

*/

Ok,i read the docs of vite-plugin-pages about parse YAML,But i dont try it. Have you try it?Is it working right?

zcyc avatar Oct 07 '22 16:10 zcyc

Ok,i read the docs of vite-plugin-pages about parse YAML,But i dont try it. Have you try it?Is it working right?

It works fine, and you can try the repo widcardw/vue-tsx-starter, the index page is applied with home layout. I forgot to deploy it to netlify, but it does work in dev mode.

widcardw avatar Oct 08 '22 00:10 widcardw

Ok,i read the docs of vite-plugin-pages about parse YAML,But i dont try it. Have you try it?Is it working right?

It works fine, and you can try the repo widcardw/vue-tsx-starter, the index page is applied with home layout. I forgot to deploy it to netlify, but it does work in dev mode.

Ok,i will try it. Thank you very much.

zcyc avatar Oct 08 '22 05:10 zcyc