国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

VuePress 靜態網站生成方法步驟

2019-11-19 12:08:52
字體:
來源:轉載
供稿:網友

使用技術:

VuePress - Vue 驅動的靜態網站生成器

倉庫地址:https://github.com/yinian-R/vuepress-demo

全局安裝

## 安裝yarn global add vuepress # 或者:npm install -g vuepress

現有項目

如果你想在一個現有項目中使用 VuePress,同時想要在該項目中管理文檔,則應該將 VuePress 安裝為本地依賴。

## 沒有項目可以初始化yarn init## 將 VuePress 作為一個本地依賴安裝yarn add -D vuepress # 或者:npm install -D vuepress## 新建一個 docs 文件夾mkdir docs## 新建一個 markdown 文件echo # Hello VuePress! > docs/README.md## 開始寫作npx vuepress dev docs

接著,在 package.json 里加一些腳本:

{ "scripts": {  "docs:dev": "vuepress dev docs",  "docs:build": "vuepress build docs" }}

基本配置

.├─ docs│ ├─ README.md│ └─ .vuepress│   └─ config.js

一個 VuePress 網站必要的配置文件是 .vuepress/config.js,它應該導出一個 JavaScript 對象:

module.exports = { title: 'Hello VuePress', description: 'Just playing around'}

靜態資源

創建public文件夾,主要用于存放靜態資源

.├─ docs│ └─ .vuepress│   └─ public│     └─ image│        └─ favicon.ico

添加網站 favicon,修改 .vuepress/config.js 內容

module.exports = {  head:[    ['link', {rel:'icon', href:'/image/favicon.ico'}]  ]};

導航欄

你可以通過 themeConfig.nav 增加一些導航欄鏈接:

module.exports = {  themeConfig: {    nav: [      { text: '主頁', link: '/' },      { text: '指南', link: '/guide/' },      {        text: '語言',        items: [          { text: '中文', link: '/language/chinese/' },          { text: 'English', link: '/language/english/' }        ]      },      { text: 'GitHub', link: 'https://github.com' }    ]  }};

首頁

需要在dosc/README.md指定 home: true

---home: trueheroImage: /image/favicon.icoheroText: Hero 標題tagline: Hero 副標題actionText: 快速上手 →actionLink: /guide/features:- title: 簡潔至上 details: 以 Markdown 為中心的項目結構,以最少的配置幫助你專注于寫作。- title: Vue驅動 details: 享受 Vue + webpack 的開發體驗,在 Markdown 中使用 Vue 組件,同時可以使用 Vue 來開發自定義主題。- title: 高性能 details: VuePress 為每個頁面預渲染生成靜態的 HTML,同時在頁面被加載的時候,將作為 SPA 運行。footer: MIT Licensed | Copyright © 2018-present Evan You---

側邊欄

想要使 側邊欄(Sidebar)生效,需要配置 themeConfig.sidebar,基本的配置,需要一個包含了多個鏈接的數組:

module.exports = {  themeConfig: {    sidebar: [      '/',      ['/hello', 'hello page']    ]  }};

部署

設置部署站點的基礎路徑。

module.exports = {  base: '/vuepress-demo/',  };

在你的項目中,創建一個如下的 deploy.sh 文件

#!/usr/bin/env bash# 確保腳本拋出遇到的錯誤set -e# 生成靜態文件npm run docs:build# 進入生成的文件夾cd docs/.vuepress/dist# 如果是發布到自定義域名# echo 'www.example.com' > CNAMEgit initgit add -Agit commit -m 'deploy'# 如果發布到 https://<USERNAME>.github.io# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master# 如果發布到 https://<USERNAME>.github.io/<REPO> git push -f git@github.com:yinian-R/vuepress-demo.git master:gh-pagescd -

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平和县| 东乌珠穆沁旗| 新和县| 凤阳县| 法库县| 宜宾县| 琼结县| 西青区| 勃利县| 永城市| 四川省| 冕宁县| 南江县| 慈利县| 宜昌市| 沁阳市| 朝阳县| 新平| 洛扎县| 兰考县| 赤峰市| 普洱| 宜昌市| 墨竹工卡县| 昭苏县| 高要市| 濉溪县| 乐都县| 新余市| 天柱县| 麻江县| 灵台县| 正定县| 广饶县| 凌云县| 思南县| 肥东县| 土默特右旗| 雷山县| 双城市| 庆阳市|