時間:2023-02-08 00:20:01 | 來源:建站知識
時間:2023-02-08 00:20:01 來源:建站知識
<user>.github.io
的倉庫。想要創(chuàng)建更多的GitHub Pages頁面,可以通過創(chuàng)建項目站點實現(xiàn)。項目站點的數(shù)量沒有限制。Settings
,找到GitHub Pages部分,選擇一個主題,之后可以再改,不選擇的話頁面可能會無法加載Enforce HTTPS
,否則訪問時會出現(xiàn)安全警告。<username>.github.io/<projectname>
訪問到了package.json
中添加一些 scripts---home: trueheroImage: /logo.jpgheroText: Giria's learning recordtagline: 個人前端學(xué)習記錄actionText: 一起梳理 →actionLink: /source/element/sidebar: falsefeatures:- title: 源碼學(xué)習 details: Element UI + Vue 源碼- title: 書籍學(xué)習 details: 記錄相關(guān)書籍的學(xué)習路徑- title: 前端相關(guān) details: 各代碼庫的學(xué)習,包括不限于NodeJS、NuxtJS、多種視圖組件庫等footer: MIT Licensed | Copyright ? 2020-present Giria---::: tip 更多博客文章可移步[Giria's Blog](https://www.giriawsh.com):::
module.exports = { themeConfig: { sidebarDepth: 2, // e'b將同時提取markdown中h2 和 h3 標題,顯示在側(cè)邊欄上。 lastUpdated: 'Last Updated',// 文檔更新時間:每個文件git最后提交的時間 searchMaxSuggestions: 10, nav: [ {text: '主頁', link: '/'}, { text: '源碼學(xué)習', items: [ {text: "Element UI", link: '/source/element/'}, {text: "Vue", link: '/source/vue/'} ], }, { text: '書籍學(xué)習', items: [ {text: "JavaScript權(quán)威指南", link: '/books/theDefinitiveGuideToJavaScript/'} ], }, { text: '前端相關(guān)', items: [ {text: "Node.js", link: '/fe/nodejs/'}, {text: "Vue.js", link: '/fe/vuejs/'}, {text: "SVG.js", link: '/fe/svgjs/'}, {text: "Nuxt框架", link: '/fe/nuxtjs/'}, ], }, {text: '博客文章', link: 'https://www.giriawsh.com'},//外鏈,可進行跳轉(zhuǎn) ], }}
目錄組織結(jié)構(gòu)如下:// .vuepress/config.jsmodule.exports = { themeConfig: { nav: [ { text: '前端相關(guān)', items: [ { text: "JS庫相關(guān)", items: [ {text: "Node.js", link: '/fe/nodejs/'}, {text: "Vue.js", link: '/fe/vuejs/'}, {text: "SVG.js", link: '/fe/svgjs/'}, ] }, { text: "框架相關(guān)", items: [ {text: "Nuxt框架", link: '/fe/nuxtjs/'}, ] }, ], }, ] }}
效果如下:themeConfig.logo
增加導(dǎo)航欄 Logo ,Logo 可以被放置在公共文件目錄:// .vuepress/config.jsmodule.exports = { themeConfig: { logo: '/assets/img/logo.png', }}
module.exports = { themeConfig: { sidebarDepth: 2, // e'b將同時提取markdown中h2 和 h3 標題,顯示在側(cè)邊欄上。 lastUpdated: 'Last Updated',// 文檔更新時間:每個文件git最后提交的時間 sidebar: { '/source/element/': [ { title: 'Element源碼分析', collapsable: false, children: [ '/source/element/1', '/source/element/2',]//這里的順序決定了在側(cè)邊欄中從上到下顯示的順序 } ], '/source/vue/': [ { title: 'Vue源碼分析', collapsable: false, children: [] } ], '/books/theDefinitiveGuideToJavaScript/': [ { title: 'JavaScript權(quán)威指南', collapsable: false, children: [ '/books/theDefinitiveGuideToJavaScript/1', '/books/theDefinitiveGuideToJavaScript/2', '/books/theDefinitiveGuideToJavaScript/3', '/books/theDefinitiveGuideToJavaScript/4', '/books/theDefinitiveGuideToJavaScript/5', ], } ], '/fe/nodejs/': [ { title: 'NodeJS初學(xué)', collapsable: false, children: [ '/fe/nodejs/start/1', '/fe/nodejs/start/2', '/fe/nodejs/start/3', '/fe/nodejs/start/4', ] }, { title: 'NodeJS深入學(xué)習', collapsable: false, children: [ '/fe/nodejs/second/test' ] } ], '/fe/svgjs/': [ { title: 'SVG學(xué)習記錄', collapsable: false, children: [ '/fe/svgjs/1', '/fe/svgjs/2', '/fe/svgjs/3', ] }, ] } },?};
如果想要達到如下多個分組的效果,可查看上面代碼中的'/fe/nodejs/'
部分,進行多個對象的配置。(上面代碼為了直觀省略了文件名)module.exports = { // 注入到當前頁面的 HTML <head> 中的標簽 head: [ ['link', {rel: 'icon', href: '/pencil.png'}], // 增加一個自定義的 favicon(網(wǎng)頁標簽的圖標) ],}
$accentColor = #e6be00//默認主題顏色$textColor = red//默認字體顏色$borderColor = #eaecef//默認邊框顏色$codeBgColor = #282c34//默認背景顏色?示例修改相關(guān)樣式f12找到需要修改的地方找到對應(yīng)class類拿過來直接用就行了.sidebar-group.is-sub-group > .sidebar-heading:not(.clickable){ opacity :1}
更多可參考:docs/.vuepress/config.js
中設(shè)置正確的 base
。https://<USERNAME>.github.io/
,則可以省略這一步,因為 base
默認即是 "/"
。https://<USERNAME>.github.io/<REPO>/
(也就是說你的倉庫在 https://github.com/<USERNAME>/<REPO>
),則將 base
設(shè)置為 "/<REPO>/"
。deploy.sh
文件(請自行判斷去掉高亮行的注釋)放置到根目錄中:#!/usr/bin/env sh?# 確保腳本拋出遇到的錯誤set -e?# 生成靜態(tài)文件npm run docs:build?# 進入生成的文件夾cd docs/.vuepress/dist?# 如果是發(fā)布到自定義域名# echo 'www.example.com' > CNAME# 后續(xù)這里我們會發(fā)布到二級域名,像我的就需要像下面這么寫:echo 'record.giriawsh.com' > CNAME?git initgit add -Agit commit -m 'deploy'?# 如果發(fā)布到 https://<USERNAME>.github.io# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master?# 如果發(fā)布到 https://<USERNAME>.github.io/<REPO># git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages?cd -
這樣我們之后每次修改后只需要點擊這個腳本進行運行即可部署。https://<USERNAME>.github.io/<REPO>
訪問到部署后的頁面了如果是參照了我之前的配置方案,這里不用寫成http://record.giriawsh.com,因為它會自己映射添加,寫二級子域名名稱record即可
關(guān)鍵詞:配置
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。