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 禁用搜索框