VuePress 1.0.0-alpha.38 发布,轻量级静态网站生成器 - 开源中国

VuePress 1.0.0-alpha.38 发布了,VuePress 是一个由 Vue 驱动的轻量级静态网站生成器,它是为了满足 Vue 自己的项目文档需求而创建的。

更新内容如下:

Bug Fixes

  • $plugin-pwa: 设置 service worker 的当前注册范围
  • $theme-default: 侧栏组项目不能包含空子项

Features

  • $core: 支持全局布局

    可以通过 siteConfig 或 themeEntryFile 使用自定义全局布局组件:

    module.exports = {
      globalLayout: '/path/to/your/global/vue/sfc'
    }

    以下是默认全局布局组件的内容,设置全局 header 和 footer 的示例:

    <template>
      <div id="global-layout">
        <header><h1>Header</h1></header>
        <component :is="layout"/>
        <footer><h1>Footer</h1></footer>
      </div>
    </template>

    <script>
    export default {
      computed: {
        layout () {
          if (this.$page.path) {
            if (this.$vuepress.isLayoutExists(this.$page.frontmatter.layout)) {
              return this.$page.frontmatter.layout
            }
            return 'Layout'
          }
          return 'NotFound'
        }
      }
    }
    </script>

    还可以按惯例直接创建组件 .vuepress/components/GlobalLayout.vue 或 themePath/layouts/GlobalLayout.vue,无需任何配置。加载优先级如下:

  • siteConfig
  • siteAgreement
  • themeEntryFile
  • themeAgreement
  • default
  • $theme-default: 通过 frontmatter 禁用搜索框

更新日志


Original url: Access
Created at: 2019-02-18 09:12:14
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论