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

feat: support layouts #56

Merged
merged 5 commits into from Feb 12, 2021
Merged

feat: support layouts #56

merged 5 commits into from Feb 12, 2021

Conversation

JohnCampionJr
Copy link
Collaborator

Sorry about that, I hit the wrong thing and screwed up my branch.

Closes #50

This is pre-plugin code for discussion. Willing to work on integrating with Vite-plugin-pages if @hannoeru is interested.

If not, can refactor into Vite-plugin-layouts instead.

@JohnCampionJr JohnCampionJr changed the title Layout Code Add Layout to Template Feb 11, 2021
@JohnCampionJr
Copy link
Collaborator Author

FYI, I have started work on a separate vite plugin for this. I think its different enough to separate from Vite-plugin-pages and this way different versions can iterate. If they should be merged at some point, we can do that later.

@hannoeru
Copy link
Collaborator

I think is better to separate it to a different plugin.
In src/layouts/_setup.ts you can use glob Import to get layout components.

@JohnCampionJr
Copy link
Collaborator Author

JohnCampionJr commented Feb 11, 2021

Now using new plugin. Probably some tweaks to be made there; open to suggestions.

https://github.com/JohnCampionJr/vite-plugin-vue-layouts

@hannoeru
Copy link
Collaborator

hannoeru commented Feb 12, 2021

Actually, what I means is you can build a component to swap layout and pass vite's glob import in to it's props.
Then maybe we can add a wrap component option in vite-plugin-page.

@JohnCampionJr
Copy link
Collaborator Author

Actually, what I means is you can build a component to swap layout and pass vite's glob import in to it's props.
Then maybe we can add a wrap component option in vite-plugin-page.

I'm really confused now. I thought you wanted it in a different plugin. I've already built it as such.

Can you add any more details to what you're suggesting now? Where would the component live? @antfu didn't want the infrastructure cluttering up Vitesse.

@hannoeru
Copy link
Collaborator

Sorry about that, I just thinking about using vite plugin or use vite's glob import with a layout component. Both works.

@JohnCampionJr
Copy link
Collaborator Author

Sorry about that, I just thinking about using vite plugin or use vite's glob import with a layout component. Both works.

I used your great work as base to build the vite plugin with a virtual module. It creates the imports the same way Vite's glob import does and feeds them to a layout component it creates and then that wraps around the routes (generated by your plugin).

@antfu antfu changed the title Add Layout to Template feat: support layouts Feb 12, 2021
@antfu antfu merged commit 8322503 into antfu-collective:master Feb 12, 2021
@antfu
Copy link
Member

antfu commented Feb 12, 2021

Great, thanks!

@JohnCampionJr JohnCampionJr deleted the layout branch February 15, 2021 02:01
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 this pull request may close these issues.

[feature request] layout feature
3 participants