vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.55k stars 4.76k forks source link

Global Footer in Default Theme #339

Closed raytu closed 6 years ago

raytu commented 6 years ago

It seems that footers are defined separately in each README.md front matter. Is there a way to define a global footer for all pages from a single file or themeConfig?

meteorlxy commented 6 years ago

Not yet in default theme.

In fact, in current default theme, only the home layout has a footer.

There is a <slot name="page-bottom" slot="bottom"/> for page layout to put something like a footer (current some ads for vuejs official theme, lol)

You can check the vuepress-theme-vue in your node_modules/ to find how to implement it.

Example:

// .vuepress/theme/Layout.vue
<template>
  <Layout>
    <footer slot="page-bottom">
      My page footer
    </footer>
  </Layout>
</template>

<script>
import Layout from '@default-theme/Layout.vue'

export default {
  components: {
    Layout,
  }
}
</script>
ghys commented 6 years ago

I have the same requirement, I tried creating a new .vuepress/theme/Layout.vue reusing the layout component from the default theme as shown above.

The problem is, my override.styl is not taken into account anymore (I override $accentColor etc.), presumably because of this: https://github.com/vuejs/vuepress/blob/d9b290b39863c51f60468b7091d82f52a6c7335a/lib/prepare.js#L64 (useDefaultTheme is now false)

Would it make sense to always copy override.styl if found, to allow custom themes based on the default theme to still override stylus variables?

ulivz commented 6 years ago

As @meteorlxy said, it shouldn't be included in default theme.

@ghys You should open another issue for feature request of override.styl in custom theme.

iamchathu commented 5 years ago

The solution is not works with current version.

imaegoo commented 4 years ago

The solution is not works with current version.

New solution for vuepress v1.5.4 -- v1.x

Create 2 files

  1. .vuepress/theme/index.js
    module.exports = {
    extend: '@vuepress/theme-default'
    }
  2. .vuepress/theme/layouts/Layout.vue
    
    <template>
    <ParentLayout>
    <template #page-bottom>
      <div>My custom footer</div>
    </template>
    </ParentLayout>
    </template>


### New solution for vuepress v2.0.0-beta.45

https://v2.vuepress.vuejs.org/reference/default-theme/extending.html
JenuelDev commented 3 years ago

Changing the footer ignores some of my plugin like the vuepress-theme-succinct.