vuepress icon indicating copy to clipboard operation
vuepress copied to clipboard

Ability to change root level components

Open axieum opened this issue 5 years ago • 4 comments

Feature request

What problem does this feature solve?

Ability to change root level components.

What does the proposed API look like?

// import GlobalLayout from 'theme'?

const app = new Vue(
  Object.assign(options, {
    router,
    render: h => h(GlobalLayout)
  })
)

How should this be implemented in your opinion?

Move hardcoded components such as .global-ui into the GlobalLayout.vue component, this almost every aspect is manageable.

Are you willing to work on this yourself?

Being new to VuePress, if the proposed solution may work, then perhaps.

axieum avatar Dec 28 '19 10:12 axieum

I'm very interested in this. Specifically, I'd like to add a <Transition> element that exists as a parent of the router element <GlobalLayout>. The GlobalLayout component is one layer too far down in the tree to be useful for this, and the devTemplate/SSRTemplate is one layer too high, if I understand correctly.

sdaitzman avatar Jan 03 '20 14:01 sdaitzman

Yes, this feature is mostly so that I can have full control of the DOM. For example, achieve a structure like:

<div id="app" theme="dark">
  <navbar />
  <!-- <main> -->
    <Content tag="main" />
  <!-- </main> -->
</div>

Edit: and no, Content component does not let us change the tag or "content__default" class name 😠

axieum avatar Jan 03 '20 15:01 axieum

@Axieum for your use case, I think the current implementation may already work. You should be able to modify your devTemplate and ssrTemplate to include a parent div of the Vue root (div#App), vary the class of that, and style according to whether the elements you’re working with are a descendant of that. Let me know if you’d like more specifics/explanation of what I mean.

None of what I just described, as far as I can tell, works for implementing a <Transition> Vue component as a parent of the router.

sdaitzman avatar Jan 03 '20 15:01 sdaitzman

This feature would be interesting.

I write a documentation about a custom VueJS (v2) framework with Vuepress (version 1.7). By default, the root element is the classic VueJs . But I need it's v-app from Vuetify.

I created a custom theme, but the result HTML contains two div with the id 'app' :

<body>
    <div id="app">
        <div id="app" data-app="true" class="v-application v-application--is-ltr theme--light" style="background: white;">
        ...
        </div>
    </div>
</body>

The first div without class come from Vuepress and the second with class come from the custom theme.

vernou avatar Aug 08 '22 15:08 vernou