Skip to content

feat: register globally theme components (close #281) #345

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

Conversation

hmatalonga
Copy link
Contributor

This pull request allows to register theme components globally, just like the components in .vuepress/components.

It makes use of options.themePath to include all *.vue in a components sub-folder to follow the existing logic.

Closes #281

@meteorlxy
Copy link
Member

For me, I prefer to put the components of my custom theme in the themePath/components directory, rather than register them as global components.

What about themePath/globalComponents ?

I don't know which solution is better, may need more discussions.

@hmatalonga
Copy link
Contributor Author

hmatalonga commented May 7, 2018

Sure thing, we should hear about the general consensus which place to put the components 👍

@yliaho
Copy link
Contributor

yliaho commented May 7, 2018

I agree with @meteorlxy – globalComponents (or similar) would be preferable.

@hmatalonga
Copy link
Contributor Author

Giving it some more thought, I agree it makes perfectly sense to have a dedicated globalComponents where only those ones are registered.

I can make that change, if you feel like it's an adequate solution for everyone 👍

@ulivz
Copy link
Member

ulivz commented May 8, 2018

Thanks for this work!

Consider this feature can be finished by a plugin. just hold it until our plugin is released. Not too long.😅

@sebiniemann
Copy link

sebiniemann commented May 15, 2018

Regarding the path name, I would vote for either for components or to rename .vuepress/components to .vuepress/globalComponents.

Differentiating the folder name between .vuepress and a theme, while serving the same purpose, seems to be an avoidable learning curve increase.

I like to think about themes as a common .vuepress functionality between multiple sites. Therefore being as closely related to each other as possible.

@AuditorCJ
Copy link

Giving it some more thought, I agree it makes perfectly sense to have a dedicated globalComponents where only those ones are registered.

I can make that change, if you feel like it's an adequate solution for everyone +1

@hmatalonga
Copy link
Contributor Author

@AuditorCJ

It was decided to wait until the plugin API is released, to add this feature as a plugin then we will revisit this discussion and decide on which directory naming to follow 😉

ulivz added a commit that referenced this pull request Jun 6, 2018
1. Move global components registration to a single plugin 'vuepress-plugin-register-global-components'
2. Support register global theme components (`${themePath}/components`) (#345)
@ulivz ulivz force-pushed the master branch 3 times, most recently from 14d9013 to c7c0cd9 Compare June 8, 2018 19:11
@ulivz ulivz force-pushed the master branch 5 times, most recently from c992e38 to c2eaff3 Compare July 12, 2018 18:01
@ulivz ulivz force-pushed the master branch 4 times, most recently from 0c3bc3a to cf1e6fc Compare July 28, 2018 08:12
@ulivz ulivz added version: next Planned to do or already included in the next(1.0.0) version and removed TBD labels Aug 20, 2018
@ulivz ulivz force-pushed the master branch 2 times, most recently from bd69d41 to 903138e Compare October 3, 2018 22:21
@ulivz ulivz force-pushed the master branch 2 times, most recently from 3f79224 to fb05066 Compare October 23, 2018 15:09
@ulivz ulivz force-pushed the master branch 3 times, most recently from 6c3127f to 71574f2 Compare December 18, 2018 18:27
@ulivz ulivz force-pushed the master branch 5 times, most recently from 316e022 to 1284944 Compare January 29, 2019 11:47
@ulivz
Copy link
Member

ulivz commented Mar 13, 2019

In 1.x, structure of a theme would be:

theme
├── global-components
│   └── xxx.vue
├── components
│   └── xxx.vue
├── layouts
│   ├── Layout.vue (Mandatory)
│   └── 404.vue
├── styles
│   ├── index.styl
│   └── palette.styl
├── index.js
├── enhanceApp.js
└── package.json

And those components under global-components will be registered as global components.

ref: https://v1.vuepress.vuejs.org/theme/writing-a-theme.html#directory-structure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version: next Planned to do or already included in the next(1.0.0) version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants