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

Cannot override components/content when using multi layer #1417

Closed
pi0 opened this issue Aug 5, 2022 · 3 comments · Fixed by #1418
Closed

Cannot override components/content when using multi layer #1417

pi0 opened this issue Aug 5, 2022 · 3 comments · Fixed by #1418

Comments

@pi0
Copy link
Member

pi0 commented Aug 5, 2022

Environment



Reproduction

https://codesandbox.io/s/eager-noyce-r9tjgs (originally posted by @CodeDredd in nuxt/framework#6382 (comment))

Describe the bug

Previously it was fine by using components:dirs and unshift a directory. But when supporting multi-layer in #1404, since we start by highest periority layer, second layers if containing components/content, their directory will be unshifted to the top, overriding user ones.

Additional context

nuxt/framework#6382

Logs

Example before hook:


[                                                                                                                                                   19:04:47
  '/Users/pooya/tmp/r9tjgs/components/global',
  '/Users/pooya/tmp/r9tjgs/components',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/app',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/docs',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/prose',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/content',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/github',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/icons'
]

After hook:

[                                                                                                                                                   19:04:47
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/content',
  '/Users/pooya/tmp/r9tjgs/components/global',
  '/Users/pooya/tmp/r9tjgs/components',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/app',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/docs',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/prose',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/content',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/github',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt-themes/docus/components/icons',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxtjs/algolia/dist/runtime/components',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxt/content/dist/runtime/components',
  '/Users/pooya/tmp/r9tjgs/node_modules/@nuxthq/studio/dist/runtime/components'
]
@CodeDredd
Copy link
Contributor

@pi0 ping 👍 😄 ... starting a fix here

@CodeDredd
Copy link
Contributor

I think you can simply reverse layers() so that last unshift goes to first

@pi0 Almost 😆

[                                                                                                                                                                                                                                                                                                                                               20:36:10
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/components/content',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/content',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/app',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/docs',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/prose',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/content',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/github',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/icons',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/components/global',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/components',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxtjs/algolia/dist/runtime/components',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt/content/dist/runtime/components',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxthq/studio/dist/runtime/components'
]

@CodeDredd
Copy link
Contributor

@pi0 Reverse is the right thing. But thats all what can be done here. If i think it right now it goes back to nuxt. Because dirs already has this state:

  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/app',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/docs',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/prose',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/content',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/github',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt-themes/docus/components/icons',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/components/global',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/components',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxtjs/algolia/dist/runtime/components',
  '/home/dredd/PhpstormProjects/storm-tail/pinia-orm/docs/node_modules/@nuxt/content/dist/runtime/components'

and only content comes then on top of it.

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

Successfully merging a pull request may close this issue.

2 participants